Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 805af9b

Browse files
1.7.2
* [*] fix
1 parent bca4fad commit 805af9b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/SphinxToolkit.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde
184184
$query_chunk_data = " SELECT * FROM {$mysql_table} ";
185185
$query_chunk_data.= $condition != '' ? " WHERE {$condition} " : '';
186186
$query_chunk_data.= " ORDER BY id DESC LIMIT {$offset}, {$chunk_size} ";
187+
188+
/*$query_chunk_data = vsprintf("SELECT * FROM %s WHERE 1 = 1 %s ORDER BY id DESC LIMIT %s, %s", [
189+
$mysql_table, ($condition != '' ? " AND {$condition} " : ''), $offset, $chunk_size
190+
]);*/
187191

188192
$sth = $mysql_connection->query($query_chunk_data);
189193

@@ -469,13 +473,12 @@ public static function rt_RebuildAbstractIndex(PDO $pdo_connection, string $sql_
469473
= $pdo_connection
470474
->query("SELECT COUNT(*) as cnt FROM {$sql_source_table} " . ($condition != '' ? " WHERE {$condition} " : ' ') )
471475
->fetchColumn();
476+
472477
$total_updated = 0;
473478

474-
if (self::$spql_options['log_before_index'])
475-
CLIConsole::say("<font color='yellow'>[{$sphinx_index}]</font> index : ", false);
479+
if (self::$spql_options['log_before_index']) CLIConsole::say("<font color='yellow'>[{$sphinx_index}]</font> index : ", false);
476480

477-
if (self::$spql_options['log_total_rows_found'])
478-
CLIConsole::say("<font color='green'>{$total_count}</font> elements found for rebuild.");
481+
if (self::$spql_options['log_total_rows_found']) CLIConsole::say("<font color='green'>{$total_count}</font> elements found for rebuild.");
479482

480483
// iterate chunks
481484
for ($i = 0; $i < ceil($total_count / $chunk_size); $i++) {
@@ -491,10 +494,9 @@ public static function rt_RebuildAbstractIndex(PDO $pdo_connection, string $sql_
491494

492495
// iterate inside chunk
493496
while ($item = $sth->fetch()) {
494-
if (self::$spql_options['log_rows_inside_chunk'])
495-
CLIConsole::say("{$sql_source_table}: {$item['id']}");
497+
if (self::$spql_options['log_rows_inside_chunk']) CLIConsole::say("{$sql_source_table}: {$item['id']}");
496498

497-
$update_set = $make_updateset_method($item);
499+
$update_set = $make_updateset_method($item); // call closure
498500

499501
self::internal_ReplaceIndex($sphinx_index, $update_set);
500502

@@ -515,8 +517,8 @@ public static function rt_RebuildAbstractIndex(PDO $pdo_connection, string $sql_
515517
CLIConsole::say("I woke up!");
516518
}
517519
} // for
518-
if (self::$spql_options['log_after_index'])
519-
CLIConsole::say("Total updated <strong>{$total_updated}</strong> elements for <font color='yellow'>{$sphinx_index}</font> RT-index. <br>");
520+
521+
if (self::$spql_options['log_after_index']) CLIConsole::say("Total updated <strong>{$total_updated}</strong> elements for <font color='yellow'>{$sphinx_index}</font> RT-index. <br>");
520522

521523
return $total_updated;
522524
}
@@ -539,7 +541,7 @@ private static function internal_ReplaceIndex(string $index_name, array $updates
539541
{
540542
if (empty($updateset)) return null;
541543

542-
return self::getInstance()
544+
return self::getInstance(self::$spql_connection)
543545
->replace()
544546
->into($index_name)
545547
->set($updateset)

0 commit comments

Comments
 (0)