Skip to content

Commit

Permalink
[BUGFIX] Respect workspace when adding language information
Browse files Browse the repository at this point in the history
And throw an exception when more than one original
language record was found

fixes #663
  • Loading branch information
hannesbochmann committed Jan 7, 2025
1 parent 7e3ac88 commit 69428d8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Classes/Service/IndexPreparationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public function prepareIndex(string $configurationKey, string $tableName, int $u
}
}

// Workspace information must be added before language information so we can set the correct l10n_parent
$this->addWorkspaceInformation($neededItems, $configurationKey, $rawRecord);
// Language information must be added before ctrl/enable information
$this->addLanguageInformation($neededItems, $tableName, $rawRecord);
$this->addEnableFieldInformation($neededItems, $tableName, $rawRecord);
$this->addCtrlFieldInformation($neededItems, $tableName, $rawRecord);
$this->addSlugInformation($neededItems, $configurationKey, $rawRecord);
$this->addWorkspaceInformation($neededItems, $configurationKey, $rawRecord);

return $neededItems;
}
Expand Down Expand Up @@ -113,11 +114,15 @@ protected function addLanguageInformation(array &$neededItems, string $tableName
->select('uid')
->from(IndexerService::TABLE_NAME)
->andWhere(...$where)
->executeQuery()
->fetchAssociative();
->executeQuery();

if ($result->rowCount() > 1) {
throw new \RuntimeException('Multiple records found for original language record of index '.$record['uid']);
}

if (isset($result['uid'])) {
$neededItems[$key]['l10n_parent'] = (int)$result['uid'];
$originalLanguageRecord = $result->fetchAssociative();
if (isset($originalLanguageRecord['uid'])) {
$neededItems[$key]['l10n_parent'] = (int)$originalLanguageRecord['uid'];
}
}
}
Expand Down

0 comments on commit 69428d8

Please sign in to comment.