@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
| 107 | 108 | // Perhaps the search method wants to add some settings? |
| 108 | 109 | require_once($sourcedir . '/Search.php'); |
| 109 | 110 | $searchAPI = findSearchAPI(); |
| 110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
| 111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
| 112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | - if ($return_config) |
|
| 114 | - return $config_vars; |
|
| 115 | + if ($return_config) { |
|
| 116 | + return $config_vars; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
| 117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | call_integration_hook('integrate_save_search_settings'); |
| 128 | 131 | |
| 129 | - if (empty($_POST['search_results_per_page'])) |
|
| 130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 132 | + if (empty($_POST['search_results_per_page'])) { |
|
| 133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 134 | + } |
|
| 131 | 135 | saveDBSettings($config_vars); |
| 132 | 136 | $_SESSION['adm-save'] = true; |
| 133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
| 177 | 181 | call_integration_hook('integrate_save_search_weights'); |
| 178 | 182 | |
| 179 | 183 | $changes = array(); |
| 180 | - foreach ($factors as $factor) |
|
| 181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
| 184 | + foreach ($factors as $factor) { |
|
| 185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
| 186 | + } |
|
| 182 | 187 | updateSettings($changes); |
| 183 | 188 | } |
| 184 | 189 | |
| 185 | 190 | $context['relative_weights'] = array('total' => 0); |
| 186 | - foreach ($factors as $factor) |
|
| 187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 191 | + foreach ($factors as $factor) { |
|
| 192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 193 | + } |
|
| 188 | 194 | |
| 189 | - foreach ($factors as $factor) |
|
| 190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 195 | + foreach ($factors as $factor) { |
|
| 196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 197 | + } |
|
| 191 | 198 | |
| 192 | 199 | createToken('admin-msw'); |
| 193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
| 216 | 223 | |
| 217 | 224 | // Detect whether a fulltext index is set. |
| 218 | - if ($context['supports_fulltext']) |
|
| 219 | - detectFulltextIndex(); |
|
| 225 | + if ($context['supports_fulltext']) { |
|
| 226 | + detectFulltextIndex(); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
| 222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
| 240 | 248 | 'language' => $language_ftx |
| 241 | 249 | ) |
| 242 | 250 | ); |
| 243 | - } |
|
| 244 | - else |
|
| 251 | + } else |
|
| 245 | 252 | { |
| 246 | 253 | // Make sure it's gone before creating it. |
| 247 | 254 | $smcFunc['db_query']('', ' |
@@ -261,8 +268,7 @@ discard block |
||
| 261 | 268 | } |
| 262 | 269 | |
| 263 | 270 | $context['fulltext_index'] = 'body'; |
| 264 | - } |
|
| 265 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 271 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 266 | 272 | { |
| 267 | 273 | checkSession('get'); |
| 268 | 274 | validateToken('admin-msm', 'get'); |
@@ -279,12 +285,12 @@ discard block |
||
| 279 | 285 | $context['fulltext_index'] = ''; |
| 280 | 286 | |
| 281 | 287 | // Go back to the default search method. |
| 282 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
| 283 | - updateSettings(array( |
|
| 288 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
| 289 | + updateSettings(array( |
|
| 284 | 290 | 'search_index' => '', |
| 285 | 291 | )); |
| 286 | - } |
|
| 287 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 292 | + } |
|
| 293 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 288 | 294 | { |
| 289 | 295 | checkSession('get'); |
| 290 | 296 | validateToken('admin-msm', 'get'); |
@@ -306,12 +312,12 @@ discard block |
||
| 306 | 312 | )); |
| 307 | 313 | |
| 308 | 314 | // Go back to the default search method. |
| 309 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 310 | - updateSettings(array( |
|
| 315 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 316 | + updateSettings(array( |
|
| 311 | 317 | 'search_index' => '', |
| 312 | 318 | )); |
| 313 | - } |
|
| 314 | - elseif (isset($_POST['save'])) |
|
| 319 | + } |
|
| 320 | + } elseif (isset($_POST['save'])) |
|
| 315 | 321 | { |
| 316 | 322 | checkSession(); |
| 317 | 323 | validateToken('admin-msmpost'); |
@@ -333,8 +339,8 @@ discard block |
||
| 333 | 339 | // Get some info about the messages table, to show its size and index size. |
| 334 | 340 | if ($db_type == 'mysql') |
| 335 | 341 | { |
| 336 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 337 | - $request = $smcFunc['db_query']('', ' |
|
| 342 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 343 | + $request = $smcFunc['db_query']('', ' |
|
| 338 | 344 | SHOW TABLE STATUS |
| 339 | 345 | FROM {string:database_name} |
| 340 | 346 | LIKE {string:table_name}', |
@@ -343,14 +349,15 @@ discard block |
||
| 343 | 349 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 344 | 350 | ) |
| 345 | 351 | ); |
| 346 | - else |
|
| 347 | - $request = $smcFunc['db_query']('', ' |
|
| 352 | + } else { |
|
| 353 | + $request = $smcFunc['db_query']('', ' |
|
| 348 | 354 | SHOW TABLE STATUS |
| 349 | 355 | LIKE {string:table_name}', |
| 350 | 356 | array( |
| 351 | 357 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 352 | 358 | ) |
| 353 | 359 | ); |
| 360 | + } |
|
| 354 | 361 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 355 | 362 | { |
| 356 | 363 | // Only do this if the user has permission to execute this query. |
@@ -362,8 +369,8 @@ discard block |
||
| 362 | 369 | } |
| 363 | 370 | |
| 364 | 371 | // Now check the custom index table, if it exists at all. |
| 365 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 366 | - $request = $smcFunc['db_query']('', ' |
|
| 372 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 373 | + $request = $smcFunc['db_query']('', ' |
|
| 367 | 374 | SHOW TABLE STATUS |
| 368 | 375 | FROM {string:database_name} |
| 369 | 376 | LIKE {string:table_name}', |
@@ -372,14 +379,15 @@ discard block |
||
| 372 | 379 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
| 373 | 380 | ) |
| 374 | 381 | ); |
| 375 | - else |
|
| 376 | - $request = $smcFunc['db_query']('', ' |
|
| 382 | + } else { |
|
| 383 | + $request = $smcFunc['db_query']('', ' |
|
| 377 | 384 | SHOW TABLE STATUS |
| 378 | 385 | LIKE {string:table_name}', |
| 379 | 386 | array( |
| 380 | 387 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
| 381 | 388 | ) |
| 382 | 389 | ); |
| 390 | + } |
|
| 383 | 391 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 384 | 392 | { |
| 385 | 393 | // Only do this if the user has permission to execute this query. |
@@ -388,8 +396,7 @@ discard block |
||
| 388 | 396 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
| 389 | 397 | $smcFunc['db_free_result']($request); |
| 390 | 398 | } |
| 391 | - } |
|
| 392 | - elseif ($db_type == 'postgresql') |
|
| 399 | + } elseif ($db_type == 'postgresql') |
|
| 393 | 400 | { |
| 394 | 401 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
| 395 | 402 | //db_extend(); |
@@ -431,38 +438,38 @@ discard block |
||
| 431 | 438 | $context['table_info']['data_length'] = (int) $row['table_size']; |
| 432 | 439 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 433 | 440 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
| 434 | - } |
|
| 435 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 441 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 436 | 442 | { |
| 437 | 443 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 438 | 444 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
| 439 | 445 | } |
| 440 | 446 | } |
| 441 | 447 | $smcFunc['db_free_result']($request); |
| 442 | - } |
|
| 443 | - else |
|
| 444 | - // Didn't work for some reason... |
|
| 448 | + } else { |
|
| 449 | + // Didn't work for some reason... |
|
| 445 | 450 | $context['table_info'] = array( |
| 446 | 451 | 'data_length' => $txt['not_applicable'], |
| 447 | 452 | 'index_length' => $txt['not_applicable'], |
| 448 | 453 | 'fulltext_length' => $txt['not_applicable'], |
| 449 | 454 | 'custom_index_length' => $txt['not_applicable'], |
| 450 | 455 | ); |
| 451 | - } |
|
| 452 | - else |
|
| 453 | - $context['table_info'] = array( |
|
| 456 | + } |
|
| 457 | + } else { |
|
| 458 | + $context['table_info'] = array( |
|
| 454 | 459 | 'data_length' => $txt['not_applicable'], |
| 455 | 460 | 'index_length' => $txt['not_applicable'], |
| 456 | 461 | 'fulltext_length' => $txt['not_applicable'], |
| 457 | 462 | 'custom_index_length' => $txt['not_applicable'], |
| 458 | 463 | ); |
| 464 | + } |
|
| 459 | 465 | |
| 460 | 466 | // Format the data and index length in kilobytes. |
| 461 | 467 | foreach ($context['table_info'] as $type => $size) |
| 462 | 468 | { |
| 463 | 469 | // If it's not numeric then just break. This database engine doesn't support size. |
| 464 | - if (!is_numeric($size)) |
|
| 465 | - break; |
|
| 470 | + if (!is_numeric($size)) { |
|
| 471 | + break; |
|
| 472 | + } |
|
| 466 | 473 | |
| 467 | 474 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
| 468 | 475 | } |
@@ -491,8 +498,9 @@ discard block |
||
| 491 | 498 | |
| 492 | 499 | // Scotty, we need more time... |
| 493 | 500 | @set_time_limit(600); |
| 494 | - if (function_exists('apache_reset_timeout')) |
|
| 495 | - @apache_reset_timeout(); |
|
| 501 | + if (function_exists('apache_reset_timeout')) { |
|
| 502 | + @apache_reset_timeout(); |
|
| 503 | + } |
|
| 496 | 504 | |
| 497 | 505 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
| 498 | 506 | $context['page_title'] = $txt['search_index_custom']; |
@@ -522,8 +530,7 @@ discard block |
||
| 522 | 530 | $context['start'] = (int) $context['index_settings']['resume_at']; |
| 523 | 531 | unset($context['index_settings']['resume_at']); |
| 524 | 532 | $context['step'] = 1; |
| 525 | - } |
|
| 526 | - else |
|
| 533 | + } else |
|
| 527 | 534 | { |
| 528 | 535 | $context['index_settings'] = array( |
| 529 | 536 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -532,12 +539,14 @@ discard block |
||
| 532 | 539 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
| 533 | 540 | |
| 534 | 541 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
| 535 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
| 536 | - $_SESSION['admin_time'] = time(); |
|
| 542 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
| 543 | + $_SESSION['admin_time'] = time(); |
|
| 544 | + } |
|
| 537 | 545 | } |
| 538 | 546 | |
| 539 | - if ($context['step'] !== 0) |
|
| 540 | - checkSession('request'); |
|
| 547 | + if ($context['step'] !== 0) { |
|
| 548 | + checkSession('request'); |
|
| 549 | + } |
|
| 541 | 550 | |
| 542 | 551 | // Step 0: let the user determine how they like their index. |
| 543 | 552 | if ($context['step'] === 0) |
@@ -566,12 +575,14 @@ discard block |
||
| 566 | 575 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
| 567 | 576 | |
| 568 | 577 | // Temporarily switch back to not using a search index. |
| 569 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 570 | - updateSettings(array('search_index' => '')); |
|
| 578 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 579 | + updateSettings(array('search_index' => '')); |
|
| 580 | + } |
|
| 571 | 581 | |
| 572 | 582 | // Don't let simultanious processes be updating the search index. |
| 573 | - if (!empty($modSettings['search_custom_index_config'])) |
|
| 574 | - updateSettings(array('search_custom_index_config' => '')); |
|
| 583 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
| 584 | + updateSettings(array('search_custom_index_config' => '')); |
|
| 585 | + } |
|
| 575 | 586 | } |
| 576 | 587 | |
| 577 | 588 | $num_messages = array( |
@@ -587,16 +598,16 @@ discard block |
||
| 587 | 598 | 'starting_id' => $context['start'], |
| 588 | 599 | ) |
| 589 | 600 | ); |
| 590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 591 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 601 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 602 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 603 | + } |
|
| 592 | 604 | |
| 593 | 605 | if (empty($num_messages['todo'])) |
| 594 | 606 | { |
| 595 | 607 | $context['step'] = 2; |
| 596 | 608 | $context['percentage'] = 80; |
| 597 | 609 | $context['start'] = 0; |
| 598 | - } |
|
| 599 | - else |
|
| 610 | + } else |
|
| 600 | 611 | { |
| 601 | 612 | // Number of seconds before the next step. |
| 602 | 613 | $stop = time() + 3; |
@@ -637,21 +648,22 @@ discard block |
||
| 637 | 648 | |
| 638 | 649 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
| 639 | 650 | |
| 640 | - if (!empty($inserts)) |
|
| 641 | - $smcFunc['db_insert']('ignore', |
|
| 651 | + if (!empty($inserts)) { |
|
| 652 | + $smcFunc['db_insert']('ignore', |
|
| 642 | 653 | '{db_prefix}log_search_words', |
| 643 | 654 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 644 | 655 | $inserts, |
| 645 | 656 | array('id_word', 'id_msg') |
| 646 | 657 | ); |
| 658 | + } |
|
| 647 | 659 | if ($num_messages['todo'] === 0) |
| 648 | 660 | { |
| 649 | 661 | $context['step'] = 2; |
| 650 | 662 | $context['start'] = 0; |
| 651 | 663 | break; |
| 664 | + } else { |
|
| 665 | + updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 652 | 666 | } |
| 653 | - else |
|
| 654 | - updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 655 | 667 | } |
| 656 | 668 | |
| 657 | 669 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -662,9 +674,9 @@ discard block |
||
| 662 | 674 | // Step 2: removing the words that occur too often and are of no use. |
| 663 | 675 | elseif ($context['step'] === 2) |
| 664 | 676 | { |
| 665 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
| 666 | - $context['step'] = 3; |
|
| 667 | - else |
|
| 677 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
| 678 | + $context['step'] = 3; |
|
| 679 | + } else |
|
| 668 | 680 | { |
| 669 | 681 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
| 670 | 682 | $stop = time() + 3; |
@@ -685,20 +697,22 @@ discard block |
||
| 685 | 697 | 'minimum_messages' => $max_messages, |
| 686 | 698 | ) |
| 687 | 699 | ); |
| 688 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 689 | - $stop_words[] = $row['id_word']; |
|
| 700 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 701 | + $stop_words[] = $row['id_word']; |
|
| 702 | + } |
|
| 690 | 703 | $smcFunc['db_free_result']($request); |
| 691 | 704 | |
| 692 | 705 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
| 693 | 706 | |
| 694 | - if (!empty($stop_words)) |
|
| 695 | - $smcFunc['db_query']('', ' |
|
| 707 | + if (!empty($stop_words)) { |
|
| 708 | + $smcFunc['db_query']('', ' |
|
| 696 | 709 | DELETE FROM {db_prefix}log_search_words |
| 697 | 710 | WHERE id_word in ({array_int:stop_words})', |
| 698 | 711 | array( |
| 699 | 712 | 'stop_words' => $stop_words, |
| 700 | 713 | ) |
| 701 | 714 | ); |
| 715 | + } |
|
| 702 | 716 | |
| 703 | 717 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
| 704 | 718 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -759,8 +773,9 @@ discard block |
||
| 759 | 773 | $searchAPI = new $search_class_name(); |
| 760 | 774 | |
| 761 | 775 | // No Support? NEXT! |
| 762 | - if (!$searchAPI->is_supported) |
|
| 763 | - continue; |
|
| 776 | + if (!$searchAPI->is_supported) { |
|
| 777 | + continue; |
|
| 778 | + } |
|
| 764 | 779 | |
| 765 | 780 | $apis[$index_name] = array( |
| 766 | 781 | 'filename' => $file, |
@@ -807,10 +822,10 @@ discard block |
||
| 807 | 822 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
| 808 | 823 | ) |
| 809 | 824 | ); |
| 810 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 811 | - $context['fulltext_index'][] = $row['indexname']; |
|
| 812 | - } |
|
| 813 | - else |
|
| 825 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 826 | + $context['fulltext_index'][] = $row['indexname']; |
|
| 827 | + } |
|
| 828 | + } else |
|
| 814 | 829 | { |
| 815 | 830 | $request = $smcFunc['db_query']('', ' |
| 816 | 831 | SHOW INDEX |
@@ -821,17 +836,19 @@ discard block |
||
| 821 | 836 | $context['fulltext_index'] = array(); |
| 822 | 837 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 823 | 838 | { |
| 824 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 825 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 839 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 840 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 826 | 841 | $context['fulltext_index'][] = $row['Key_name']; |
| 842 | + } |
|
| 827 | 843 | $smcFunc['db_free_result']($request); |
| 828 | 844 | |
| 829 | - if (is_array($context['fulltext_index'])) |
|
| 830 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 845 | + if (is_array($context['fulltext_index'])) { |
|
| 846 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 847 | + } |
|
| 831 | 848 | } |
| 832 | 849 | |
| 833 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 834 | - $request = $smcFunc['db_query']('', ' |
|
| 850 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 851 | + $request = $smcFunc['db_query']('', ' |
|
| 835 | 852 | SHOW TABLE STATUS |
| 836 | 853 | FROM {string:database_name} |
| 837 | 854 | LIKE {string:table_name}', |
@@ -840,20 +857,22 @@ discard block |
||
| 840 | 857 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 841 | 858 | ) |
| 842 | 859 | ); |
| 843 | - else |
|
| 844 | - $request = $smcFunc['db_query']('', ' |
|
| 860 | + } else { |
|
| 861 | + $request = $smcFunc['db_query']('', ' |
|
| 845 | 862 | SHOW TABLE STATUS |
| 846 | 863 | LIKE {string:table_name}', |
| 847 | 864 | array( |
| 848 | 865 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 849 | 866 | ) |
| 850 | 867 | ); |
| 868 | + } |
|
| 851 | 869 | |
| 852 | 870 | if ($request !== false) |
| 853 | 871 | { |
| 854 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 855 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
| 872 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 873 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
| 856 | 874 | $context['cannot_create_fulltext'] = true; |
| 875 | + } |
|
| 857 | 876 | $smcFunc['db_free_result']($request); |
| 858 | 877 | } |
| 859 | 878 | } |