546 |
546 |
{
|
547 |
547 |
if ($source instanceof Qom\SelectorInterface) {
|
548 |
548 |
$tableName = $source->getSelectorName();
|
|
549 |
$forceRecordReloadInWorkspace = false;
|
549 |
550 |
} elseif ($source instanceof Qom\JoinInterface) {
|
550 |
551 |
$tableName = $source->getRight()->getSelectorName();
|
|
552 |
$forceRecordReloadInWorkspace = true;
|
551 |
553 |
} else {
|
552 |
554 |
// No proper source, so we do not have a table name here
|
553 |
555 |
// we cannot do an overlay and return the original rows instead.
|
... | ... | |
654 |
656 |
{
|
655 |
657 |
if ($source instanceof Qom\SelectorInterface) {
|
656 |
658 |
$tableName = $source->getSelectorName();
|
|
659 |
$forceRecordReloadInWorkspace = false;
|
657 |
660 |
} elseif ($source instanceof Qom\JoinInterface) {
|
658 |
661 |
$tableName = $source->getRight()->getSelectorName();
|
|
662 |
$forceRecordReloadInWorkspace = true;
|
659 |
663 |
} else {
|
660 |
664 |
// No proper source, so we do not have a table name here
|
661 |
665 |
// we cannot do an overlay and return the original rows instead.
|
... | ... | |
677 |
681 |
// by the table and if there's only one row in the result set
|
678 |
682 |
// (applying this to all rows does not work, since the sorting
|
679 |
683 |
// order would be destroyed and possible limits not met anymore)
|
680 |
|
if (!empty($workspaceUid)
|
681 |
|
&& BackendUtility::isTableWorkspaceEnabled($tableName)
|
682 |
|
&& count($rows) === 1
|
683 |
|
) {
|
|
684 |
$isInWorkspaceContext = !empty($workspaceUid)
|
|
685 |
&& BackendUtility::isTableWorkspaceEnabled($tableName);
|
|
686 |
if ($isInWorkspaceContext && count($rows) === 1) {
|
684 |
687 |
$versionId = $workspaceUid;
|
685 |
688 |
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
|
686 |
689 |
$queryBuilder->getRestrictions()->removeAll();
|
... | ... | |
697 |
700 |
->fetchAll();
|
698 |
701 |
if (!empty($movePlaceholder)) {
|
699 |
702 |
$rows = $movePlaceholder;
|
|
703 |
// Records have been "reloaded"
|
|
704 |
$forceRecordReloadInWorkspace = false;
|
700 |
705 |
}
|
701 |
706 |
}
|
702 |
707 |
$overlaidRows = [];
|
703 |
708 |
foreach ($rows as $row) {
|
|
709 |
$originalRow = $row;
|
|
710 |
// If current row is a translation or we are in a workspace preview, select its parent
|
|
711 |
if (isset($tableName) && isset($GLOBALS['TCA'][$tableName])
|
|
712 |
&& isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
|
|
713 |
&& isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
|
|
714 |
&& isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']])
|
|
715 |
&& (
|
|
716 |
$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0
|
|
717 |
|| ($forceRecordReloadInWorkspace && $isInWorkspaceContext)
|
|
718 |
)
|
|
719 |
) {
|
|
720 |
$queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
|
|
721 |
$queryBuilder->getRestrictions()->removeAll();
|
|
722 |
$row = $queryBuilder
|
|
723 |
->select($tableName . '.*')
|
|
724 |
->from($tableName)
|
|
725 |
->where(
|
|
726 |
$queryBuilder->expr()->eq(
|
|
727 |
$tableName . '.uid',
|
|
728 |
$queryBuilder->createNamedParameter(
|
|
729 |
$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] == 0 ? $row['uid'] : $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']],
|
|
730 |
\PDO::PARAM_INT
|
|
731 |
)
|
|
732 |
),
|
|
733 |
$queryBuilder->expr()->eq(
|
|
734 |
$tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'],
|
|
735 |
$queryBuilder->createNamedParameter(
|
|
736 |
0,
|
|
737 |
\PDO::PARAM_INT
|
|
738 |
)
|
|
739 |
)
|
|
740 |
)
|
|
741 |
->setMaxResults(1)
|
|
742 |
->execute()
|
|
743 |
->fetch();
|
|
744 |
}
|
704 |
745 |
$pageRepository->versionOL($tableName, $row, true);
|
705 |
746 |
$querySettings = $query->getQuerySettings();
|
706 |
747 |
if (is_array($row) && $querySettings->getLanguageOverlayMode()) {
|
... | ... | |
728 |
769 |
}
|
729 |
770 |
}
|
730 |
771 |
if ($row !== null && is_array($row)) {
|
|
772 |
if ($forceRecordReloadInWorkspace && $isInWorkspaceContext) {
|
|
773 |
// Add additional fields back to the overlaid record
|
|
774 |
$row = array_merge($originalRow, $row);
|
|
775 |
}
|
731 |
776 |
$overlaidRows[] = $row;
|
732 |
777 |
}
|
733 |
778 |
}
|