Commit 1b14468a authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[TASK] Remove hard-coded l10n_parent fields for pages

Due to the change of the pages_language_overlay migration, a lot
of hard-coded "l10n_parent" and "sys_language_uid" fields for
pages have been introduced.

This should be changed into a common function in DataHandler
and the TCA option should be used instead.

Resolves: #83013
Releases: master
Change-Id: I43a33aac1015436109d1ca7b3ea200c78d2a2fb9
Reviewed-on: https://review.typo3.org/54664


Reviewed-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 1432d9ec
...@@ -1517,9 +1517,9 @@ class EditDocumentController ...@@ -1517,9 +1517,9 @@ class EditDocumentController
// Get all available languages for the page // Get all available languages for the page
// If editing a page, the translations of the current UID need to be fetched // If editing a page, the translations of the current UID need to be fetched
if ($table === 'pages') { if ($table === 'pages') {
$row = BackendUtility::getRecord($table, $uid, 'l10n_parent'); $row = BackendUtility::getRecord($table, $uid, $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']);
// Ensure the check is always done against the default language page // Ensure the check is always done against the default language page
$langRows = $this->getLanguages($row['l10n_parent'] ?: $uid); $langRows = $this->getLanguages($row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] ?: $uid);
} else { } else {
$langRows = $this->getLanguages($pid); $langRows = $this->getLanguages($pid);
} }
...@@ -1726,8 +1726,8 @@ class EditDocumentController ...@@ -1726,8 +1726,8 @@ class EditDocumentController
// Add join with pages translations to only show active languages // Add join with pages translations to only show active languages
$queryBuilder->from('pages', 'o') $queryBuilder->from('pages', 'o')
->where( ->where(
$queryBuilder->expr()->eq('o.sys_language_uid', $queryBuilder->quoteIdentifier('s.uid')), $queryBuilder->expr()->eq('o.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'], $queryBuilder->quoteIdentifier('s.uid')),
$queryBuilder->expr()->eq('o.l10n_parent', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)) $queryBuilder->expr()->eq('o.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
); );
} }
......
...@@ -318,7 +318,7 @@ class PageLayoutController ...@@ -318,7 +318,7 @@ class PageLayoutController
'pages', 'pages',
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'sys_language.uid', 'sys_language.uid',
$queryBuilder->quoteIdentifier('pages.sys_language_uid') $queryBuilder->quoteIdentifier('pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'])
) )
) )
->where( ->where(
...@@ -327,7 +327,7 @@ class PageLayoutController ...@@ -327,7 +327,7 @@ class PageLayoutController
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'pages.l10n_parent', 'pages.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->orX( $queryBuilder->expr()->orX(
...@@ -345,7 +345,7 @@ class PageLayoutController ...@@ -345,7 +345,7 @@ class PageLayoutController
) )
) )
->groupBy( ->groupBy(
'pages.sys_language_uid', 'pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'],
'sys_language.uid', 'sys_language.uid',
'sys_language.pid', 'sys_language.pid',
'sys_language.tstamp', 'sys_language.tstamp',
...@@ -644,11 +644,11 @@ class PageLayoutController ...@@ -644,11 +644,11 @@ class PageLayoutController
->from('pages') ->from('pages')
->where( ->where(
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'l10n_parent', $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'sys_language_uid', $GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
) )
) )
...@@ -994,6 +994,8 @@ class PageLayoutController ...@@ -994,6 +994,8 @@ class PageLayoutController
if ($this->pageIsNotLockedForEditors() && $this->getBackendUser()->checkLanguageAccess(0)) { if ($this->pageIsNotLockedForEditors() && $this->getBackendUser()->checkLanguageAccess(0)) {
// Edit localized pages only when one specific language is selected // Edit localized pages only when one specific language is selected
if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) { if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages'); ->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions() $queryBuilder->getRestrictions()
...@@ -1005,11 +1007,11 @@ class PageLayoutController ...@@ -1005,11 +1007,11 @@ class PageLayoutController
->from('pages') ->from('pages')
->where( ->where(
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'l10n_parent', $localizationParentField,
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'sys_language_uid', $languageField,
$queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
) )
) )
......
...@@ -60,7 +60,10 @@ class DatabasePageLanguageOverlayRows implements FormDataProviderInterface ...@@ -60,7 +60,10 @@ class DatabasePageLanguageOverlayRows implements FormDataProviderInterface
$rows = $queryBuilder->select('*') $rows = $queryBuilder->select('*')
->from('pages') ->from('pages')
->where($queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT))) ->where($queryBuilder->expr()->eq(
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
))
->execute() ->execute()
->fetchAll(); ->fetchAll();
......
...@@ -107,8 +107,8 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid ...@@ -107,8 +107,8 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
$pid = $row['pid']; $pid = $row['pid'];
} }
$pageRecord = BackendUtility::getRecord('pages', $pid); $pageRecord = BackendUtility::getRecord('pages', $pid);
if ((int)$pageRecord['l10n_parent'] > 0) { if ((int)$pageRecord[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] > 0) {
$pid = (int)$pageRecord['l10n_parent']; $pid = (int)$pageRecord[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']];
} }
$result['inlineFirstPid'] = (int)$pid; $result['inlineFirstPid'] = (int)$pid;
} }
......
...@@ -448,6 +448,8 @@ abstract class AbstractRecordList ...@@ -448,6 +448,8 @@ abstract class AbstractRecordList
public function initializeLanguages() public function initializeLanguages()
{ {
// Look up page overlays: // Look up page overlays:
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages'); ->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions() $queryBuilder->getRestrictions()
...@@ -459,15 +461,15 @@ abstract class AbstractRecordList ...@@ -459,15 +461,15 @@ abstract class AbstractRecordList
->from('pages') ->from('pages')
->where( ->where(
$queryBuilder->expr()->andX( $queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)), $queryBuilder->expr()->eq($localizationParentField, $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)),
$queryBuilder->expr()->gt('sys_language_uid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)) $queryBuilder->expr()->gt($languageField, $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
) )
) )
->execute(); ->execute();
$this->pageOverlays = []; $this->pageOverlays = [];
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$this->pageOverlays[$row['sys_language_uid']] = $row; $this->pageOverlays[$row[$languageField]] = $row;
} }
$this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id); $this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id);
......
...@@ -2448,7 +2448,7 @@ class PageLayoutView implements LoggerAwareInterface ...@@ -2448,7 +2448,7 @@ class PageLayoutView implements LoggerAwareInterface
'sys_language', 'sys_language',
'pages', 'pages',
'pages', 'pages',
$queryBuilder->expr()->eq('sys_language.uid', $queryBuilder->quoteIdentifier('pages.sys_language_uid')) $queryBuilder->expr()->eq('sys_language.uid', $queryBuilder->quoteIdentifier('pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField']))
) )
->where( ->where(
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
...@@ -2456,7 +2456,7 @@ class PageLayoutView implements LoggerAwareInterface ...@@ -2456,7 +2456,7 @@ class PageLayoutView implements LoggerAwareInterface
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'pages.l10n_parent', 'pages.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->orX( $queryBuilder->expr()->orX(
...@@ -2474,7 +2474,7 @@ class PageLayoutView implements LoggerAwareInterface ...@@ -2474,7 +2474,7 @@ class PageLayoutView implements LoggerAwareInterface
) )
) )
->groupBy( ->groupBy(
'pages.sys_language_uid', 'pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'],
'sys_language.uid', 'sys_language.uid',
'sys_language.pid', 'sys_language.pid',
'sys_language.tstamp', 'sys_language.tstamp',
...@@ -4292,9 +4292,12 @@ class PageLayoutView implements LoggerAwareInterface ...@@ -4292,9 +4292,12 @@ class PageLayoutView implements LoggerAwareInterface
->from('pages') ->from('pages')
->where( ->where(
$queryBuilder->expr()->andX( $queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)), $queryBuilder->expr()->eq(
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->gt( $queryBuilder->expr()->gt(
'sys_language_uid', $GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
) )
) )
...@@ -4303,7 +4306,7 @@ class PageLayoutView implements LoggerAwareInterface ...@@ -4303,7 +4306,7 @@ class PageLayoutView implements LoggerAwareInterface
$this->pageOverlays = []; $this->pageOverlays = [];
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$this->pageOverlays[$row['sys_language_uid']] = $row; $this->pageOverlays[$row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]] = $row;
} }
$this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id); $this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id);
......
...@@ -579,7 +579,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication ...@@ -579,7 +579,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
} }
// Return 0 if page is not within the allowed web mount // Return 0 if page is not within the allowed web mount
// Always do this for the default language page record // Always do this for the default language page record
if (!$this->isInWebMount($row['l10n_parent'] ?: $row['uid'])) { if (!$this->isInWebMount($row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] ?: $row['uid'])) {
return Permission::NOTHING; return Permission::NOTHING;
} }
$out = Permission::NOTHING; $out = Permission::NOTHING;
......
...@@ -1040,8 +1040,8 @@ class DataHandler implements LoggerAwareInterface ...@@ -1040,8 +1040,8 @@ class DataHandler implements LoggerAwareInterface
if ($theRealPid >= 0) { if ($theRealPid >= 0) {
// Checks if records can be inserted on this $pid. // Checks if records can be inserted on this $pid.
// If this is a page translation, the check needs to be done for the l10n_parent record // If this is a page translation, the check needs to be done for the l10n_parent record
if ($table === 'pages' && $incomingFieldArray['sys_language_uid'] > 0 && $incomingFieldArray['l10n_parent'] > 0) { if ($table === 'pages' && $incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0 && $incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0) {
$recordAccess = $this->checkRecordInsertAccess($table, $incomingFieldArray['l10n_parent']); $recordAccess = $this->checkRecordInsertAccess($table, $incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
} else { } else {
$recordAccess = $this->checkRecordInsertAccess($table, $theRealPid); $recordAccess = $this->checkRecordInsertAccess($table, $theRealPid);
} }
...@@ -1313,10 +1313,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -1313,10 +1313,7 @@ class DataHandler implements LoggerAwareInterface
// Points to a page on which to insert the element, possibly in the top of the page // Points to a page on which to insert the element, possibly in the top of the page
if ($pid >= 0) { if ($pid >= 0) {
// Ensure that the "pid" is not a translated page ID, but the default page ID // Ensure that the "pid" is not a translated page ID, but the default page ID
$localizationParent = $this->recordInfo('pages', $pid, 'l10n_parent'); $pid = $this->getDefaultLanguagePageId($pid);
if ($localizationParent['l10n_parent'] > 0) {
$pid = (int)$localizationParent['l10n_parent'];
}
// The numerical pid is inserted in the data array // The numerical pid is inserted in the data array
$fieldArray['pid'] = $pid; $fieldArray['pid'] = $pid;
// If this table is sorted we better find the top sorting number // If this table is sorted we better find the top sorting number
...@@ -1333,13 +1330,8 @@ class DataHandler implements LoggerAwareInterface ...@@ -1333,13 +1330,8 @@ class DataHandler implements LoggerAwareInterface
} else { } else {
// Here we fetch the PID of the record that we point to // Here we fetch the PID of the record that we point to
$record = $this->recordInfo($table, abs($pid), 'pid'); $record = $this->recordInfo($table, abs($pid), 'pid');
$pid = $record['pid'];
// Ensure that the "pid" is not a translated page ID, but the default page ID // Ensure that the "pid" is not a translated page ID, but the default page ID
$localizationParent = $this->recordInfo('pages', $pid, 'l10n_parent'); $fieldArray['pid'] = $this->getDefaultLanguagePageId($record['pid']);
if ($localizationParent['l10n_parent'] > 0) {
$pid = (int)$localizationParent['l10n_parent'];
}
$fieldArray['pid'] = $pid;
} }
return $fieldArray; return $fieldArray;
} }
...@@ -4419,13 +4411,12 @@ class DataHandler implements LoggerAwareInterface ...@@ -4419,13 +4411,12 @@ class DataHandler implements LoggerAwareInterface
// Check if this is a translation of a page, if so then it just needs to be kept "sorting" in sync // Check if this is a translation of a page, if so then it just needs to be kept "sorting" in sync
// Usually called from moveL10nOverlayRecords() // Usually called from moveL10nOverlayRecords()
$originalTranslationRecord = null;
if ($table === 'pages') { if ($table === 'pages') {
$fullRecord = $this->recordInfo($table, $uid, 'sys_language_uid, l10n_parent'); $defaultLanguagePageId = $this->getDefaultLanguagePageId((int)$uid);
if ($fullRecord['sys_language_uid'] > 0) { if ($defaultLanguagePageId !== (int)$uid) {
$originalTranslationRecord = $this->recordInfo($table, $fullRecord['l10n_parent'], 'pid,' . $sortRow); $originalTranslationRecord = $this->recordInfo($table, $defaultLanguagePageId, 'pid,' . $sortRow);
$updateFields[$sortRow] = $originalTranslationRecord[$sortRow]; $updateFields[$sortRow] = $originalTranslationRecord[$sortRow];
// Ensure that the PID is always the same as the original page // Ensure that the PID is always the same as the default language page
$destPid = $originalTranslationRecord['pid']; $destPid = $originalTranslationRecord['pid'];
} }
} }
...@@ -5096,8 +5087,8 @@ class DataHandler implements LoggerAwareInterface ...@@ -5096,8 +5087,8 @@ class DataHandler implements LoggerAwareInterface
$fullLanguageAccessCheck = true; $fullLanguageAccessCheck = true;
if ($table === 'pages') { if ($table === 'pages') {
// If this is a page translation, the full language access check should not be done // If this is a page translation, the full language access check should not be done
$recordInfo = $this->recordInfo($table, $uid, 'l10n_parent'); $defaultLanguagePageId = $this->getDefaultLanguagePageId($uid);
if ($recordInfo['l10n_parent'] > 0) { if ($defaultLanguagePageId !== $uid) {
$fullLanguageAccessCheck = false; $fullLanguageAccessCheck = false;
} }
} }
...@@ -5421,10 +5412,10 @@ class DataHandler implements LoggerAwareInterface ...@@ -5421,10 +5412,10 @@ class DataHandler implements LoggerAwareInterface
// If we may at all delete this page // If we may at all delete this page
// If this is a page translation, do the check against the perms_* of the default page // If this is a page translation, do the check against the perms_* of the default page
// Because it is currently only deleting the translation // Because it is currently only deleting the translation
$fullRecord = $this->recordInfo('pages', $uid, 'l10n_parent'); $defaultLanguagePageId = $this->getDefaultLanguagePageId($uid);
if ($fullRecord['l10n_parent'] > 0) { if ($defaultLanguagePageId !== $uid) {
if ($this->doesRecordExist('pages', (int)$fullRecord['l10n_parent'], 'delete')) { if ($this->doesRecordExist('pages', (int)$defaultLanguagePageId, 'delete')) {
$isTranslatedPage = $fullRecord['l10n_parent'] > 0; $isTranslatedPage = true;
} else { } else {
return 'Attempt to delete page without permissions'; return 'Attempt to delete page without permissions';
} }
...@@ -6089,10 +6080,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -6089,10 +6080,7 @@ class DataHandler implements LoggerAwareInterface
// Update child records if change to pid is required (only if the current record is not on a workspace): // Update child records if change to pid is required (only if the current record is not on a workspace):
if ($thePidToUpdate) { if ($thePidToUpdate) {
// Ensure that only the default language page is used as PID // Ensure that only the default language page is used as PID
$localizationParent = $this->recordInfo('pages', $thePidToUpdate, 'l10n_parent'); $thePidToUpdate = $this->getDefaultLanguagePageId($thePidToUpdate);
if ($localizationParent['l10n_parent'] > 0) {
$thePidToUpdate = $localizationParent['l10n_parent'];
}
// ensure, only live page ids are used as 'pid' values // ensure, only live page ids are used as 'pid' values
$liveId = BackendUtility::getLiveVersionIdOfRecord('pages', $theUidToUpdate); $liveId = BackendUtility::getLiveVersionIdOfRecord('pages', $theUidToUpdate);
if ($liveId !== null) { if ($liveId !== null) {
...@@ -6479,12 +6467,8 @@ class DataHandler implements LoggerAwareInterface ...@@ -6479,12 +6467,8 @@ class DataHandler implements LoggerAwareInterface
} }
// permissions check for page translations need to be done on the parent page // permissions check for page translations need to be done on the parent page
if ($table === 'pages') { if ($table === 'pages') {
$defaultLanguagePage = $this->recordInfo($table, $id, 'l10n_parent'); $defaultLanguagePageId = $this->getDefaultLanguagePageId($id);
if ($defaultLanguagePage['l10n_parent'] > 0) { $res = $this->doesRecordExist($table, $defaultLanguagePageId, 'edit') ? 1 : 0;
$res = $this->doesRecordExist($table, $defaultLanguagePage['l10n_parent'], 'edit');
} else {
$res = $this->doesRecordExist($table, $id, 'edit') ? 1 : 0;
}
} elseif ($this->doesRecordExist($table, $id, 'edit')) { } elseif ($this->doesRecordExist($table, $id, 'edit')) {
$res = 1; $res = 1;
} }
...@@ -7517,7 +7501,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -7517,7 +7501,7 @@ class DataHandler implements LoggerAwareInterface
$queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->eq( $queryBuilder->expr()->eq(
'sys_language_uid', $GLOBALS['TCA'][$table]['ctrl']['languageField'],
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
), ),
$queryBuilder->expr()->lt( $queryBuilder->expr()->lt(
...@@ -8407,12 +8391,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -8407,12 +8391,7 @@ class DataHandler implements LoggerAwareInterface
$pageIdsThatNeedCacheFlush = []; $pageIdsThatNeedCacheFlush = [];
if ($table === 'pages') { if ($table === 'pages') {
// Find out if the record is a get the original page // Find out if the record is a get the original page
$row = $this->recordInfo($table, $uid, 'pid,sys_language_uid,l10n_parent'); $pageUid = $this->getDefaultLanguagePageId($uid);
if ((int)$row['l10n_parent'] > 0) {
$pageUid = $row['l10n_parent'];
} else {
$pageUid = $uid;
}
// Builds list of pages on the SAME level as this page (siblings) // Builds list of pages on the SAME level as this page (siblings)
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
...@@ -8747,6 +8726,23 @@ class DataHandler implements LoggerAwareInterface ...@@ -8747,6 +8726,23 @@ class DataHandler implements LoggerAwareInterface
* *
*****************************/ *****************************/
/**
* Find out if the record is a get the original page
*
* @param int $pageId the page UID (can be the default page record, or a page translation record ID)
* @return int the page UID of the default page record
*/
protected function getDefaultLanguagePageId(int $pageId): int
{
$localizationParentFieldName = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$row = $this->recordInfo('pages', $pageId, $localizationParentFieldName);
$localizationParent = (int)$row[$localizationParentFieldName];
if ($localizationParent > 0) {
return $localizationParent;
}
return $pageId;
}
/** /**
* Preprocesses field array based on field type. Some fields must be adjusted * Preprocesses field array based on field type. Some fields must be adjusted
* before going to database. This is done on the copy of the field array because * before going to database. This is done on the copy of the field array because
......
...@@ -751,6 +751,8 @@ class FileList ...@@ -751,6 +751,8 @@ class FileList
public function initializeLanguages() public function initializeLanguages()
{ {
// Look up page overlays: // Look up page overlays:
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages'); ->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions() $queryBuilder->getRestrictions()
...@@ -762,9 +764,12 @@ class FileList ...@@ -762,9 +764,12 @@ class FileList
->from('pages') ->from('pages')
->where( ->where(
$queryBuilder->expr()->andX( $queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)), $queryBuilder->expr()->eq(
$localizationParentField,
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->gt( $queryBuilder->expr()->gt(
'sys_language_uid', $languageField,
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
) )
) )
...@@ -773,7 +778,7 @@ class FileList ...@@ -773,7 +778,7 @@ class FileList
$this->pageOverlays = []; $this->pageOverlays = [];
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$this->pageOverlays[$row['sys_language_uid']] = $row; $this->pageOverlays[$row[$languageField]] = $row;
} }
$this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id); $this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id);
......
...@@ -468,11 +468,11 @@ class PageRepository implements LoggerAwareInterface ...@@ -468,11 +468,11 @@ class PageRepository implements LoggerAwareInterface
->from('pages') ->from('pages')
->where( ->where(
$queryBuilder->expr()->in( $queryBuilder->expr()->in(
'l10n_parent',