@@ -1613,6 +1613,51 @@ function UpgradeOptions()
16131613 $ is_debug = true ;
16141614 }
16151615
1616+ // Detect whether a fulltext index is set.
1617+ $ request = $ smcFunc ['db_query ' ]('' , '
1618+ SHOW INDEX
1619+ FROM {db_prefix}messages ' ,
1620+ array (
1621+ )
1622+ );
1623+
1624+ $ _SESSION ['dropping_index ' ] = false ;
1625+
1626+ // If there's a fulltext index, we need to drop it first...
1627+ if ($ request !== false || $ smcFunc ['db_num_rows ' ]($ request ) != 0 )
1628+ {
1629+ while ($ row = $ smcFunc ['db_fetch_assoc ' ]($ request ))
1630+ if ($ row ['Column_name ' ] == 'body ' && (isset ($ row ['Index_type ' ]) && $ row ['Index_type ' ] == 'FULLTEXT ' || isset ($ row ['Comment ' ]) && $ row ['Comment ' ] == 'FULLTEXT ' ))
1631+ $ upcontext ['fulltext_index ' ][] = $ row ['Key_name ' ];
1632+ $ smcFunc ['db_free_result ' ]($ request );
1633+
1634+ if (isset ($ upcontext ['fulltext_index ' ]))
1635+ $ upcontext ['fulltext_index ' ] = array_unique ($ upcontext ['fulltext_index ' ]);
1636+ }
1637+
1638+ // Drop it and make a note...
1639+ if (!empty ($ upcontext ['fulltext_index ' ]))
1640+ {
1641+ $ _SESSION ['dropping_index ' ] = true ;
1642+
1643+ $ smcFunc ['db_query ' ]('' , '
1644+ ALTER TABLE {db_prefix}messages
1645+ DROP INDEX ' . implode (',
1646+ DROP INDEX ' , $ upcontext ['fulltext_index ' ]),
1647+ array (
1648+ 'db_error_skip ' => true ,
1649+ )
1650+ );
1651+
1652+ // Update the settings table
1653+ $ smcFunc ['db_insert ' ]('replace ' ,
1654+ '{db_prefix}settings ' ,
1655+ array ('variable ' => 'string ' , 'value ' => 'string ' ),
1656+ array ('db_search_index ' , '' ),
1657+ array ('variable ' )
1658+ );
1659+ }
1660+
16161661 // If we're not backing up then jump one.
16171662 if (empty ($ _POST ['backup ' ]))
16181663 $ upcontext ['current_step ' ]++;
@@ -3052,51 +3097,6 @@ function ConvertUtf8()
30523097 list ($ upcontext ['database_charset ' ]) = explode ('_ ' , $ column_info ['Collation ' ]);
30533098 $ upcontext ['database_charset ' ] = in_array ($ upcontext ['database_charset ' ], $ charsets ) ? array_search ($ upcontext ['database_charset ' ], $ charsets ) : $ upcontext ['database_charset ' ];
30543099
3055- // Detect whether a fulltext index is set.
3056- $ request = $ smcFunc ['db_query ' ]('' , '
3057- SHOW INDEX
3058- FROM {db_prefix}messages ' ,
3059- array (
3060- )
3061- );
3062-
3063- $ upcontext ['dropping_index ' ] = false ;
3064-
3065- // If there's a fulltext index, we need to drop it first...
3066- if ($ request !== false || $ smcFunc ['db_num_rows ' ]($ request ) != 0 )
3067- {
3068- while ($ row = $ smcFunc ['db_fetch_assoc ' ]($ request ))
3069- if ($ row ['Column_name ' ] == 'body ' && (isset ($ row ['Index_type ' ]) && $ row ['Index_type ' ] == 'FULLTEXT ' || isset ($ row ['Comment ' ]) && $ row ['Comment ' ] == 'FULLTEXT ' ))
3070- $ upcontext ['fulltext_index ' ][] = $ row ['Key_name ' ];
3071- $ smcFunc ['db_free_result ' ]($ request );
3072-
3073- if (isset ($ upcontext ['fulltext_index ' ]))
3074- $ upcontext ['fulltext_index ' ] = array_unique ($ upcontext ['fulltext_index ' ]);
3075- }
3076-
3077- // Drop it and make a note...
3078- if (!empty ($ upcontext ['fulltext_index ' ]))
3079- {
3080- $ upcontext ['dropping_index ' ] = true ;
3081-
3082- $ smcFunc ['db_query ' ]('' , '
3083- ALTER TABLE {db_prefix}messages
3084- DROP INDEX ' . implode (',
3085- DROP INDEX ' , $ upcontext ['fulltext_index ' ]),
3086- array (
3087- 'db_error_skip ' => true ,
3088- )
3089- );
3090-
3091- // Update the settings table
3092- $ smcFunc ['db_insert ' ]('replace ' ,
3093- '{db_prefix}settings ' ,
3094- array ('variable ' => 'string ' , 'value ' => 'string ' ),
3095- array ('db_search_index ' , '' ),
3096- array ('variable ' )
3097- );
3098- }
3099-
31003100 // Figure out what charset we should be converting from...
31013101 $ lang_charsets = array (
31023102 'arabic ' => 'windows-1256 ' ,
@@ -3470,7 +3470,7 @@ function ConvertUtf8()
34703470 }
34713471 $ smcFunc ['db_free_result ' ]($ request );
34723472
3473- if ($ upcontext ['dropping_index ' ] && $ command_line )
3473+ if (! empty ( $ _SESSION ['dropping_index ' ]) && $ command_line )
34743474 {
34753475 echo "\n" . '' , $ txt ['upgrade_fulltext_error ' ], '' ;
34763476 flush ();
@@ -4905,11 +4905,6 @@ function template_convert_utf8()
49054905 ' , $ txt ['upgrade_current_table ' ], ' "<span id="current_table"> ' , $ upcontext ['cur_table_name ' ], '</span>"
49064906 </h3> ' ;
49074907
4908- // If we dropped their index, let's let them know
4909- if ($ upcontext ['dropping_index ' ])
4910- echo '
4911- <p id="indexmsg" class=" ' , $ upcontext ['cur_table_num ' ] == $ upcontext ['table_count ' ] ? 'inline_block ' : 'hidden ' , '> ' , $ txt ['upgrade_fulltext ' ], '</p> ' ;
4912-
49134908 // Completion notification
49144909 echo '
49154910 <p id="commess" class=" ' , $ upcontext ['cur_table_num ' ] == $ upcontext ['table_count ' ] ? 'inline_block ' : 'hidden ' , '"> ' , $ txt ['upgrade_conversion_proceed ' ], '</p> ' ;
@@ -4957,9 +4952,6 @@ function onConversionUpdate(oXMLDoc)
49574952 if (iTableNum == ' , $ upcontext ['table_count ' ], ')
49584953 {
49594954 document.getElementById( \'commess \').classList.remove( \'hidden \');
4960- if (document.getElementById( \'indexmsg \') != null) {
4961- document.getElementById( \'indexmsg \').classList.remove( \'hidden \');
4962- }
49634955 document.getElementById( \'current_tab \').classList.add( \'hidden \');
49644956 document.getElementById( \'contbutt \').disabled = 0;
49654957 document.getElementById( \'utf8_done \').value = 1;
@@ -5123,6 +5115,11 @@ function doTheDelete(theCheck)
51235115 ' , $ txt ['upgrade_luck ' ], '<br>
51245116 Simple Machines
51255117 </p> ' ;
5118+
5119+ // If we dropped their index, let's let them know
5120+ if (!empty ($ _SESSION ['dropping_index ' ]))
5121+ echo '
5122+ <p id="indexmsg"> ' , $ txt ['upgrade_fulltext_error ' ], '</p> ' ;
51265123}
51275124
51285125/**
0 commit comments