Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

l10n_parent of workspace index points to the wrong index #663

Open
okmiim opened this issue Feb 5, 2022 · 0 comments
Open

l10n_parent of workspace index points to the wrong index #663

okmiim opened this issue Feb 5, 2022 · 0 comments
Labels

Comments

@okmiim
Copy link
Collaborator

okmiim commented Feb 5, 2022

l10n_parent of workspace index points to the wrong index.

The l10n_parent of a translated record in the workspace points to the live index.
However, it should point to the workspace index with the default language.
This should only be the case when a workspace index with the default language exists, since the original index is "marked as deleted".

This seems to be more complicated...
Might only be relevant in some edge cases and needs more thinking about different combinations.

Notes

In the case of workspaces, the last query matches multiple entries. Returns

  • LIVE version
  • Entry with DELETED placeholder
  • WS version

protected function addLanguageInformation(array &$neededItems, string $tableName, array $record): void
{
$languageField = $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] ?? false; // e.g. sys_language_uid
$transPointer = $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] ?? false; // e.g. l10n_parent
if ($transPointer && (int)$record[$transPointer] > 0) {
foreach ($neededItems as $key => $value) {
$originalRecord = BackendUtility::getRecord($value['foreign_table'], $value['foreign_uid'], $transPointer);
$searchFor = $value;
$searchFor['foreign_uid'] = (int)$originalRecord[$transPointer];
$db = HelperUtility::getDatabaseConnection(IndexerService::TABLE_NAME);
$q = $db->createQueryBuilder();
$where = [];
foreach ($searchFor as $field => $val) {
if (\is_string($val)) {
$where[] = $q->expr()->eq($field, $q->quote($val));
} else {
$where[] = $q->expr()->eq($field, (int)$val);
}
}
$result = $q->select('uid')->from(IndexerService::TABLE_NAME)->andWhere(...$where)->execute()->fetch();
if (isset($result['uid'])) {
$neededItems[$key]['l10n_parent'] = (int)$result['uid'];
}

@okmiim okmiim added the bug label Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant