Fix MeilisearchConsistencyCommand: remove unused variable, redundant array_values, always-true condition
- Remove unused $indexes variable (listIndexes() kept as health check) - Make $fixMissing parameter required (always passed), remove && $fixMissing check - Remove redundant array_values() on array_map result (already a list) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,7 @@ class MeilisearchConsistencyCommand extends Command
|
||||
$totalMissing = 0;
|
||||
|
||||
try {
|
||||
$indexes = $this->meilisearch->listIndexes();
|
||||
$this->meilisearch->listIndexes();
|
||||
} catch (\Throwable $e) {
|
||||
$io->error('Meilisearch unreachable: '.$e->getMessage());
|
||||
|
||||
@@ -127,7 +127,7 @@ class MeilisearchConsistencyCommand extends Command
|
||||
*
|
||||
* @return array{int, int}
|
||||
*/
|
||||
private function diffAndReport(string $index, array $meiliIds, array $dbIds, bool $fix, SymfonyStyle $io, ?\Closure $fixMissing = null): array
|
||||
private function diffAndReport(string $index, array $meiliIds, array $dbIds, bool $fix, SymfonyStyle $io, \Closure $fixMissing): array
|
||||
{
|
||||
$orphans = array_diff($meiliIds, $dbIds);
|
||||
$missing = array_diff($dbIds, $meiliIds);
|
||||
@@ -141,7 +141,7 @@ class MeilisearchConsistencyCommand extends Command
|
||||
|
||||
if (\count($missing) > 0) {
|
||||
$io->text(sprintf(' [%s] %d missing', $index, \count($missing)));
|
||||
if ($fix && $fixMissing) {
|
||||
if ($fix) {
|
||||
$fixMissing($missing);
|
||||
}
|
||||
}
|
||||
@@ -310,7 +310,7 @@ class MeilisearchConsistencyCommand extends Command
|
||||
private function createUserIndex(string $index, array $dbUsers, bool $isOrganizer, SymfonyStyle $io): array
|
||||
{
|
||||
$this->meilisearch->request('POST', self::INDEXES_ENDPOINT, ['uid' => $index, 'primaryKey' => 'id']);
|
||||
$docs = array_values(array_map(fn (User $u) => $this->userToDocument($u, $isOrganizer), $dbUsers));
|
||||
$docs = array_map(fn (User $u) => $this->userToDocument($u, $isOrganizer), $dbUsers);
|
||||
$io->text(sprintf(' [%s] Created index, indexing %d user(s)', $index, \count($docs)));
|
||||
if ([] !== $docs) {
|
||||
$this->meilisearch->addDocuments($index, $docs);
|
||||
|
||||
Reference in New Issue
Block a user