Bug #88951 » typo3dbbackend.patch

Lars Peter Søndergaard, 2019-09-27 09:03

View differences:

typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php
704 704
            $pageRepository->versionOL($tableName, $row, true);
705 705
            $querySettings = $query->getQuerySettings();
706 706
            if (is_array($row) && $querySettings->getLanguageOverlayMode()) {
707
                $languageUid = (int)$querySettings->getLanguageUid();
708
                if (!$querySettings->getRespectSysLanguage()
709
                    && isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']])
710
                    && $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] > 0
711
                    && (!$query instanceof Query || !$query->getParentQuery())
712
                ) {
713
                    //no parent query means we're processing the aggregate root.
714
                    //respectSysLanguage is false which means that records returned by the query
715
                    //might be from different languages (which is desired).
716
                    //So we need to force language used for overlay to the language of the current record.
717
                    $languageUid = $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']];
718
                }
719
                if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']) && $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0) {
720
                    //force overlay by faking default language record, as getRecordOverlay can only handle default language records
721
                    $row['uid'] = $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']];
722
                    $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] = 0;
723
                }
707 724
                if ($tableName === 'pages') {
708 725
                    $row = $pageRepository->getPageOverlay($row, $querySettings->getLanguageUid());
709
                } else {
710
                    $languageUid = (int)$querySettings->getLanguageUid();
711
                    if (!$querySettings->getRespectSysLanguage()
712
                        && isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']])
713
                        && $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] > 0
714
                        && (!$query instanceof Query || !$query->getParentQuery())
715
                    ) {
716
                        //no parent query means we're processing the aggregate root.
717
                        //respectSysLanguage is false which means that records returned by the query
718
                        //might be from different languages (which is desired).
719
                        //So we need to force language used for overlay to the language of the current record.
720
                        $languageUid = $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']];
721
                    }
722
                    if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']) && $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0) {
723
                        //force overlay by faking default language record, as getRecordOverlay can only handle default language records
724
                        $row['uid'] = $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']];
725
                        $row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] = 0;
726
                    // the data mapper only checks for _LOCALIZED_UID when setting '_localizedUid' property
727
                    // and not _PAGES_OVERLAY_UID. This is the easy fix.
728
                    if (!empty($row['_PAGES_OVERLAY_UID']) && $row['_PAGES_OVERLAY_UID']) {
729
                        $row['_LOCALIZED_UID'] = $row['_PAGES_OVERLAY_UID'];
726 730
                    }
731
                } else {
727 732
                    $row = $pageRepository->getRecordOverlay($tableName, $row, $languageUid, (string)$querySettings->getLanguageOverlayMode());
728 733
                }
729 734
            }
    (1-1/1)