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
// Get all available languages for the page
// If editing a page, the translations of the current UID need to be fetched
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
$langRows = $this->getLanguages($row['l10n_parent'] ?: $uid);
$langRows = $this->getLanguages($row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] ?: $uid);
} else {
$langRows = $this->getLanguages($pid);
}
......@@ -1726,8 +1726,8 @@ class EditDocumentController
// Add join with pages translations to only show active languages
$queryBuilder->from('pages', 'o')
->where(
$queryBuilder->expr()->eq('o.sys_language_uid', $queryBuilder->quoteIdentifier('s.uid')),
$queryBuilder->expr()->eq('o.l10n_parent', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
$queryBuilder->expr()->eq('o.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'], $queryBuilder->quoteIdentifier('s.uid')),
$queryBuilder->expr()->eq('o.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
);
}
......
......@@ -318,7 +318,7 @@ class PageLayoutController
'pages',
$queryBuilder->expr()->eq(
'sys_language.uid',
$queryBuilder->quoteIdentifier('pages.sys_language_uid')
$queryBuilder->quoteIdentifier('pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'])
)
)
->where(
......@@ -327,7 +327,7 @@ class PageLayoutController
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pages.l10n_parent',
'pages.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->orX(
......@@ -345,7 +345,7 @@ class PageLayoutController
)
)
->groupBy(
'pages.sys_language_uid',
'pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'],
'sys_language.uid',
'sys_language.pid',
'sys_language.tstamp',
......@@ -644,11 +644,11 @@ class PageLayoutController
->from('pages')
->where(
$queryBuilder->expr()->eq(
'l10n_parent',
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'sys_language_uid',
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
)
)
......@@ -994,6 +994,8 @@ class PageLayoutController
if ($this->pageIsNotLockedForEditors() && $this->getBackendUser()->checkLanguageAccess(0)) {
// Edit localized pages only when one specific language is selected
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)
->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
......@@ -1005,11 +1007,11 @@ class PageLayoutController
->from('pages')
->where(
$queryBuilder->expr()->eq(
'l10n_parent',
$localizationParentField,
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'sys_language_uid',
$languageField,
$queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
)
)
......
......@@ -60,7 +60,10 @@ class DatabasePageLanguageOverlayRows implements FormDataProviderInterface
$rows = $queryBuilder->select('*')
->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()
->fetchAll();
......
......@@ -107,8 +107,8 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
$pid = $row['pid'];
}
$pageRecord = BackendUtility::getRecord('pages', $pid);
if ((int)$pageRecord['l10n_parent'] > 0) {
$pid = (int)$pageRecord['l10n_parent'];
if ((int)$pageRecord[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] > 0) {
$pid = (int)$pageRecord[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']];
}
$result['inlineFirstPid'] = (int)$pid;
}
......
......@@ -448,6 +448,8 @@ abstract class AbstractRecordList
public function initializeLanguages()
{
// Look up page overlays:
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
......@@ -459,15 +461,15 @@ abstract class AbstractRecordList
->from('pages')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)),
$queryBuilder->expr()->gt('sys_language_uid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
$queryBuilder->expr()->eq($localizationParentField, $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)),
$queryBuilder->expr()->gt($languageField, $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
)
)
->execute();
$this->pageOverlays = [];
while ($row = $result->fetch()) {
$this->pageOverlays[$row['sys_language_uid']] = $row;
$this->pageOverlays[$row[$languageField]] = $row;
}
$this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id);
......
......@@ -2448,7 +2448,7 @@ class PageLayoutView implements LoggerAwareInterface
'sys_language',
'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(
$queryBuilder->expr()->eq(
......@@ -2456,7 +2456,7 @@ class PageLayoutView implements LoggerAwareInterface
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pages.l10n_parent',
'pages.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->orX(
......@@ -2474,7 +2474,7 @@ class PageLayoutView implements LoggerAwareInterface
)
)
->groupBy(
'pages.sys_language_uid',
'pages.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'],
'sys_language.uid',
'sys_language.pid',
'sys_language.tstamp',
......@@ -4292,9 +4292,12 @@ class PageLayoutView implements LoggerAwareInterface
->from('pages')
->where(
$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(
'sys_language_uid',
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
......@@ -4303,7 +4306,7 @@ class PageLayoutView implements LoggerAwareInterface
$this->pageOverlays = [];
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);
......
......@@ -579,7 +579,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
}
// Return 0 if page is not within the allowed web mount
// 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;
}
$out = Permission::NOTHING;
......
......@@ -1040,8 +1040,8 @@ class DataHandler implements LoggerAwareInterface
if ($theRealPid >= 0) {
// 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 ($table === 'pages' && $incomingFieldArray['sys_language_uid'] > 0 && $incomingFieldArray['l10n_parent'] > 0) {
$recordAccess = $this->checkRecordInsertAccess($table, $incomingFieldArray['l10n_parent']);
if ($table === 'pages' && $incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0 && $incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0) {
$recordAccess = $this->checkRecordInsertAccess($table, $incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
} else {
$recordAccess = $this->checkRecordInsertAccess($table, $theRealPid);
}
......@@ -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
if ($pid >= 0) {
// Ensure that the "pid" is not a translated page ID, but the default page ID
$localizationParent = $this->recordInfo('pages', $pid, 'l10n_parent');
if ($localizationParent['l10n_parent'] > 0) {
$pid = (int)$localizationParent['l10n_parent'];
}
$pid = $this->getDefaultLanguagePageId($pid);
// The numerical pid is inserted in the data array
$fieldArray['pid'] = $pid;
// If this table is sorted we better find the top sorting number
......@@ -1333,13 +1330,8 @@ class DataHandler implements LoggerAwareInterface
} else {
// Here we fetch the PID of the record that we point to
$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
$localizationParent = $this->recordInfo('pages', $pid, 'l10n_parent');
if ($localizationParent['l10n_parent'] > 0) {
$pid = (int)$localizationParent['l10n_parent'];
}
$fieldArray['pid'] = $pid;
$fieldArray['pid'] = $this->getDefaultLanguagePageId($record['pid']);
}
return $fieldArray;
}
......@@ -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
// Usually called from moveL10nOverlayRecords()
$originalTranslationRecord = null;
if ($table === 'pages') {
$fullRecord = $this->recordInfo($table, $uid, 'sys_language_uid, l10n_parent');
if ($fullRecord['sys_language_uid'] > 0) {
$originalTranslationRecord = $this->recordInfo($table, $fullRecord['l10n_parent'], 'pid,' . $sortRow);
$defaultLanguagePageId = $this->getDefaultLanguagePageId((int)$uid);
if ($defaultLanguagePageId !== (int)$uid) {
$originalTranslationRecord = $this->recordInfo($table, $defaultLanguagePageId, 'pid,' . $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'];
}
}
......@@ -5096,8 +5087,8 @@ class DataHandler implements LoggerAwareInterface
$fullLanguageAccessCheck = true;
if ($table === 'pages') {
// If this is a page translation, the full language access check should not be done
$recordInfo = $this->recordInfo($table, $uid, 'l10n_parent');
if ($recordInfo['l10n_parent'] > 0) {
$defaultLanguagePageId = $this->getDefaultLanguagePageId($uid);
if ($defaultLanguagePageId !== $uid) {
$fullLanguageAccessCheck = false;
}
}
......@@ -5421,10 +5412,10 @@ class DataHandler implements LoggerAwareInterface
// If we may at all delete this 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
$fullRecord = $this->recordInfo('pages', $uid, 'l10n_parent');
if ($fullRecord['l10n_parent'] > 0) {
if ($this->doesRecordExist('pages', (int)$fullRecord['l10n_parent'], 'delete')) {
$isTranslatedPage = $fullRecord['l10n_parent'] > 0;
$defaultLanguagePageId = $this->getDefaultLanguagePageId($uid);
if ($defaultLanguagePageId !== $uid) {
if ($this->doesRecordExist('pages', (int)$defaultLanguagePageId, 'delete')) {
$isTranslatedPage = true;
} else {
return 'Attempt to delete page without permissions';
}
......@@ -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):
if ($thePidToUpdate) {
// Ensure that only the default language page is used as PID
$localizationParent = $this->recordInfo('pages', $thePidToUpdate, 'l10n_parent');
if ($localizationParent['l10n_parent'] > 0) {
$thePidToUpdate = $localizationParent['l10n_parent'];
}
$thePidToUpdate = $this->getDefaultLanguagePageId($thePidToUpdate);
// ensure, only live page ids are used as 'pid' values
$liveId = BackendUtility::getLiveVersionIdOfRecord('pages', $theUidToUpdate);
if ($liveId !== null) {
......@@ -6479,12 +6467,8 @@ class DataHandler implements LoggerAwareInterface
}
// permissions check for page translations need to be done on the parent page
if ($table === 'pages') {
$defaultLanguagePage = $this->recordInfo($table, $id, 'l10n_parent');
if ($defaultLanguagePage['l10n_parent'] > 0) {
$res = $this->doesRecordExist($table, $defaultLanguagePage['l10n_parent'], 'edit');
} else {
$res = $this->doesRecordExist($table, $id, 'edit') ? 1 : 0;
}
$defaultLanguagePageId = $this->getDefaultLanguagePageId($id);
$res = $this->doesRecordExist($table, $defaultLanguagePageId, 'edit') ? 1 : 0;
} elseif ($this->doesRecordExist($table, $id, 'edit')) {
$res = 1;
}
......@@ -7517,7 +7501,7 @@ class DataHandler implements LoggerAwareInterface
$queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'sys_language_uid',
$GLOBALS['TCA'][$table]['ctrl']['languageField'],
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->lt(
......@@ -8407,12 +8391,7 @@ class DataHandler implements LoggerAwareInterface
$pageIdsThatNeedCacheFlush = [];
if ($table === 'pages') {
// Find out if the record is a get the original page
$row = $this->recordInfo($table, $uid, 'pid,sys_language_uid,l10n_parent');
if ((int)$row['l10n_parent'] > 0) {
$pageUid = $row['l10n_parent'];
} else {
$pageUid = $uid;
}
$pageUid = $this->getDefaultLanguagePageId($uid);
// Builds list of pages on the SAME level as this page (siblings)
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
......@@ -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
* before going to database. This is done on the copy of the field array because
......
......@@ -751,6 +751,8 @@ class FileList
public function initializeLanguages()
{
// Look up page overlays:
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
......@@ -762,9 +764,12 @@ class FileList
->from('pages')
->where(
$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',
$languageField,
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
......@@ -773,7 +778,7 @@ class FileList
$this->pageOverlays = [];
while ($row = $result->fetch()) {
$this->pageOverlays[$row['sys_language_uid']] = $row;
$this->pageOverlays[$row[$languageField]] = $row;
}
$this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id);
......
......@@ -468,11 +468,11 @@ class PageRepository implements LoggerAwareInterface
->from('pages')
->where(
$queryBuilder->expr()->in(
'l10n_parent',
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($page_ids, Connection::PARAM_INT_ARRAY)
),
$queryBuilder->expr()->eq(
'sys_language_uid',
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($lUid, \PDO::PARAM_INT)
)
)
......@@ -485,7 +485,7 @@ class PageRepository implements LoggerAwareInterface
$row['_PAGES_OVERLAY'] = true;
$row['_PAGES_OVERLAY_UID'] = $row['uid'];
$row['_PAGES_OVERLAY_LANGUAGE'] = $lUid;
$origUid = $row['l10n_parent'];
$origUid = $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']];
// Unset vital fields that are NOT allowed to be overlaid:
unset($row['uid']);
unset($row['pid']);
......@@ -696,7 +696,7 @@ class PageRepository implements LoggerAwareInterface
$queryBuilder->createNamedParameter($pageIds, Connection::PARAM_INT_ARRAY)
),
$queryBuilder->expr()->eq(
'sys_language_uid',
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
QueryHelper::stripLogicalOperatorPrefix($this->where_hid_del),
......
......@@ -968,11 +968,11 @@ class AdminPanelView
->from('pages')
->where(
$queryBuilder->expr()->eq(
'l10n_parent',
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'sys_language_uid',
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($tsfe->sys_language_uid, \PDO::PARAM_INT)
)
)
......
......@@ -397,13 +397,13 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
->from('pages')
->where(
$queryBuilder->expr()->eq(
'l10n_parent',
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
)
)
->andWhere(
$queryBuilder->expr()->eq(
'sys_language_uid',
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($langId, \PDO::PARAM_INT)
)
)
......
......@@ -618,6 +618,8 @@ class RecordList
}
}
// Then, subtract the languages which are already on the page:
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language');
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->select('sys_language.uid AS uid', 'sys_language.title AS title')
......@@ -626,7 +628,7 @@ class RecordList
'sys_language',
'pages',
'pages',
$queryBuilder->expr()->eq('sys_language.uid', $queryBuilder->quoteIdentifier('pages.sys_language_uid'))
$queryBuilder->expr()->eq('sys_language.uid', $queryBuilder->quoteIdentifier('pages.' . $languageField))
)
->where(
$queryBuilder->expr()->eq(
......@@ -634,7 +636,7 @@ class RecordList
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'pages.l10n_parent',
'pages.' . $localizationParentField,
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$queryBuilder->expr()->orX(
......@@ -652,7 +654,7 @@ class RecordList
)
)
->groupBy(
'pages.sys_language_uid',
'pages.' . $languageField,
'sys_language.uid',
'sys_language.pid',
'sys_language.tstamp',
......
......@@ -2071,8 +2071,9 @@ class DatabaseRecordList
$params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
$icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
$linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
$l10nParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '';
$deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
. ' data-l10parent="' . htmlspecialchars($row['l10n_parent']) . '"'
. ' data-l10parent="' . ($l10nParentField ? htmlspecialchars($row[$l10nParentField]) : '') . '"'
. ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
. ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
. '>' . $icon . '</a>';
......@@ -4134,6 +4135,8 @@ class DatabaseRecordList
public function initializeLanguages()
{
// Look up page overlays:
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
......@@ -4145,9 +4148,9 @@ class DatabaseRecordList
->from('pages')
->where(
$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',
$languageField,
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
......@@ -4156,7 +4159,7 @@ class DatabaseRecordList
$this->pageOverlays = [];
while ($row = $result->fetch()) {
$this->pageOverlays[$row['sys_language_uid']] = $row;
$this->pageOverlays[$row[$languageField]] = $row;
}
$this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id);
......
......@@ -306,6 +306,8 @@ class ViewModuleController extends ActionController
*/
protected function getPreviewLanguages()
{
$localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$pageIdToShow = (int)GeneralUtility::_GP('id');
$modSharedTSconfig = BackendUtility::getModTSconfig($pageIdToShow, 'mod.SHARED');
if ($modSharedTSconfig['properties']['view.']['disableLanguageSelector'] === '1') {
......@@ -331,11 +333,11 @@ class ViewModuleController extends ActionController
'sys_language',
'pages',
'o',
$queryBuilder->expr()->eq('o.sys_language_uid', $queryBuilder->quoteIdentifier('sys_language.uid'))
$queryBuilder->expr()->eq('o.' . $languageField, $queryBuilder->quoteIdentifier('sys_language.uid'))
)
->where(
$queryBuilder->expr()->eq(
'o.l10n_parent',
'o.' . $localizationParentField,
$queryBuilder->createNamedParameter($pageIdToShow, \PDO::PARAM_INT)
)
)
......
......@@ -701,7 +701,7 @@ class WorkspaceService implements SingletonInterface
->from('pages')
->where(
$queryBuilder->expr()->eq(
'l10n_parent',
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)