Bug #81208 » 81208_v9.diff
Classes/Persistence/Generic/Storage/Typo3DbBackend.php | ||
---|---|---|
{
|
||
if ($source instanceof Qom\SelectorInterface) {
|
||
$tableName = $source->getSelectorName();
|
||
$forceRecordReloadInWorkspace = false;
|
||
} elseif ($source instanceof Qom\JoinInterface) {
|
||
$tableName = $source->getRight()->getSelectorName();
|
||
$forceRecordReloadInWorkspace = true;
|
||
} else {
|
||
// No proper source, so we do not have a table name here
|
||
// we cannot do an overlay and return the original rows instead.
|
||
... | ... | |
// by the table and if there's only one row in the result set
|
||
// (applying this to all rows does not work, since the sorting
|
||
// order would be destroyed and possible limits not met anymore)
|
||
if (!empty($workspaceUid)
|
||
&& BackendUtility::isTableWorkspaceEnabled($tableName)
|
||
&& count($rows) === 1
|
||
$isInWorkspaceContext = !empty($workspaceUid)
|
||
&& BackendUtility::isTableWorkspaceEnabled($tableName);
|
||
if ($isInWorkspaceContext && count($rows) === 1
|
||
) {
|
||
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
|
||
$queryBuilder->getRestrictions()->removeAll();
|
||
... | ... | |
->fetch();
|
||
if (!empty($movePlaceholder)) {
|
||
$rows = [$movePlaceholder];
|
||
// Records have been "reloaded"
|
||
$forceRecordReloadInWorkspace = false;
|
||
}
|
||
}
|
||
$overlaidRows = [];
|
||
foreach ($rows as $row) {
|
||
// If current row is a translation select its parent
|
||
$originalRow = $row;
|
||
// If current row is a translation or we are in a workspace preview, select its parent
|
||
if (isset($tableName) && isset($GLOBALS['TCA'][$tableName])
|
||
&& isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
|
||
&& isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
|
||
&& isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']])
|
||
&& $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0
|
||
&& (
|
||
$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0
|
||
|| ($forceRecordReloadInWorkspace && $isInWorkspaceContext)
|
||
)
|
||
) {
|
||
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
|
||
$queryBuilder->getRestrictions()->removeAll();
|
||
... | ... | |
$row = $pageRepository->getRecordOverlay($tableName, $row, $querySettings->getLanguageUid(), $overlayMode);
|
||
}
|
||
if (is_array($row)) {
|
||
if ($forceRecordReloadInWorkspace && $isInWorkspaceContext) {
|
||
// Add additional fields back to the overlaid record
|
||
$row = array_merge($originalRow, $row);
|
||
//$row = array_merge(...$row);
|
||
}
|
||
$overlaidRows[] = $row;
|
||
}
|
||
}
|
||
... | ... | |
{
|
||
if ($source instanceof Qom\SelectorInterface) {
|
||
$tableName = $source->getSelectorName();
|
||
$forceRecordReloadInWorkspace = false;
|
||
} elseif ($source instanceof Qom\JoinInterface) {
|
||
$tableName = $source->getRight()->getSelectorName();
|
||
$forceRecordReloadInWorkspace = true;
|
||
} else {
|
||
// No proper source, so we do not have a table name here
|
||
// we cannot do an overlay and return the original rows instead.
|
||
... | ... | |
// by the table and if there's only one row in the result set
|
||
// (applying this to all rows does not work, since the sorting
|
||
// order would be destroyed and possible limits not met anymore)
|
||
if (!empty($workspaceUid)
|
||
&& BackendUtility::isTableWorkspaceEnabled($tableName)
|
||
&& count($rows) === 1
|
||
) {
|
||
$isInWorkspaceContext = !empty($workspaceUid)
|
||
&& BackendUtility::isTableWorkspaceEnabled($tableName);
|
||
if ($isInWorkspaceContext && count($rows) === 1) {
|
||
$versionId = $workspaceUid;
|
||
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
|
||
$queryBuilder->getRestrictions()->removeAll();
|
||
... | ... | |
->fetchAll();
|
||
if (!empty($movePlaceholder)) {
|
||
$rows = $movePlaceholder;
|
||
// Records have been "reloaded"
|
||
$forceRecordReloadInWorkspace = false;
|
||
}
|
||
}
|
||
$overlaidRows = [];
|
||
foreach ($rows as $row) {
|
||
$originalRow = $row;
|
||
// If current row is a translation or we are in a workspace preview, select its parent
|
||
if (isset($tableName) && isset($GLOBALS['TCA'][$tableName])
|
||
&& isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
|
||
&& isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
|
||
&& isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']])
|
||
&& (
|
||
$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0
|
||
|| ($forceRecordReloadInWorkspace && $isInWorkspaceContext)
|
||
)
|
||
) {
|
||
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
|
||
$queryBuilder->getRestrictions()->removeAll();
|
||
$row = $queryBuilder
|
||
->select($tableName . '.*')
|
||
->from($tableName)
|
||
->where(
|
||
$queryBuilder->expr()->eq(
|
||
$tableName . '.uid',
|
||
$queryBuilder->createNamedParameter(
|
||
$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']],
|
||
\PDO::PARAM_INT
|
||
)
|
||
),
|
||
$queryBuilder->expr()->eq(
|
||
$tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'],
|
||
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
|
||
)
|
||
)
|
||
->setMaxResults(1)
|
||
->execute()
|
||
->fetch();
|
||
}
|
||
$pageRepository->versionOL($tableName, $row, true);
|
||
$querySettings = $query->getQuerySettings();
|
||
if (is_array($row) && $querySettings->getLanguageOverlayMode()) {
|
||
... | ... | |
}
|
||
}
|
||
if ($row !== null && is_array($row)) {
|
||
if ($forceRecordReloadInWorkspace && $isInWorkspaceContext) {
|
||
// Add additional fields back to the overlaid record
|
||
$row = array_merge($originalRow, $row);
|
||
}
|
||
$overlaidRows[] = $row;
|
||
}
|
||
}
|