DifferentLanguageFallbackThenDefaultLanguageForPages.patch

Alex Kellner, 2018-10-30 14:48

Download (32.4 KB)

View differences:

typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php
650 650
            ) {
651 651
                if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], [-1, 0])) {
652 652
                    $overlayMode = $querySettings->getLanguageMode() === 'strict' ? 'hideNonTranslated' : '';
653
                    $row = $pageRepository->getRecordOverlay($tableName, $row, $querySettings->getLanguageUid(), $overlayMode);
653
                    $row = $pageRepository->getRecordOverlayWithFallback(
654
                        $tableName,
655
                        $row,
656
                        $querySettings->getLanguageUid(),
657
                        $overlayMode
658
                    );
654 659
                }
655 660
            }
656 661
            if ($row !== null && is_array($row)) {
typo3/sysext/frontend/Classes/Aspect/FileMetadataOverlayAspect.php
35 35
    {
36 36
        $overlaidMetaData = $data->getArrayCopy();
37 37
        $this->getTsfe()->sys_page->versionOL('sys_file_metadata', $overlaidMetaData);
38
        $overlaidMetaData = $this->getTsfe()->sys_page->getRecordOverlay(
38
        $overlaidMetaData = $this->getTsfe()->sys_page->getRecordOverlayWithFallback(
39 39
            'sys_file_metadata',
40
            $overlaidMetaData,
41
            $this->getTsfe()->sys_language_content,
42
            $this->getTsfe()->sys_language_contentOL
40
            $overlaidMetaData
43 41
        );
44 42
        if ($overlaidMetaData !== null) {
45 43
            $data->exchangeArray($overlaidMetaData);
typo3/sysext/frontend/Classes/Category/Collection/CategoryCollection.php
162 162
                if ($this->getItemTableName() === 'pages') {
163 163
                    $record = $tsfe->sys_page->getPageOverlay($record);
164 164
                } else {
165
                    $record = $tsfe->sys_page->getRecordOverlay(
165
                    $record = $this->getFrontendObject()->sys_page->getRecordOverlayWithFallback(
166 166
                        $this->getItemTableName(),
167
                        $record,
168
                        $tsfe->sys_language_content,
169
                        $tsfe->sys_language_contentOL
167
                        $record
170 168
                    );
171 169
                }
172 170
            }
typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php
197 197
            if ($referencesForeignTable === 'pages') {
198 198
                $element = $pageRepository->getPageOverlay($element);
199 199
            } else {
200
                $element = $pageRepository->getRecordOverlay(
201
                    $referencesForeignTable,
202
                    $element,
203
                    $GLOBALS['TSFE']->sys_language_content,
204
                    $GLOBALS['TSFE']->sys_language_contentOL
205
                );
200
                $element = $pageRepository->getRecordOverlayWithFallback($referencesForeignTable, $element);
206 201
            }
207 202
        }
208 203

  
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
1283 1283
                $tok = true;
1284 1284
                // There is an alternative language active AND the current page requires a translation:
1285 1285
                if ($tsfe->sys_language_uid && GeneralUtility::hideIfNotTranslated($data['l18n_cfg'])) {
1286
                    if (!$data['_PAGES_OVERLAY']) {
1286
                    if (!$data['_PAGES_OVERLAY'] || (int)$data['sys_language_uid'] !== (int)$GLOBALS['TSFE']->sys_language_uid) {
1287 1287
                        $tok = false;
1288 1288
                    }
1289 1289
                }
......
2226 2226
        while ($row = $statement->fetch()) {
2227 2227
            $this->sys_page->versionOL('tt_content', $row);
2228 2228
            if ($tsfe->sys_language_contentOL && $basePageRow['_PAGES_OVERLAY_LANGUAGE']) {
2229
                $row = $this->sys_page->getRecordOverlay('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE'], $tsfe->sys_language_contentOL);
2229
                $row = $this->sys_page->getRecordOverlayWithFallback('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE']);
2230 2230
            }
2231 2231
            if ($this->mconf['sectionIndex.']['type'] !== 'all') {
2232 2232
                $doIncludeInSectionIndex = $row['sectionIndex'] >= 1;
typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
49 49
        // Reset items and data
50 50
        $this->itemArray = [];
51 51
        $this->data = [];
52
        $tsfe = $this->getTypoScriptFrontendController();
52 53

  
53 54
        $theValue = '';
54
        $originalRec = $GLOBALS['TSFE']->currentRecord;
55
        $originalRec = $tsfe->currentRecord;
55 56
        // If the currentRecord is set, we register, that this record has invoked this function.
56 57
        // It's should not be allowed to do this again then!!
57 58
        if ($originalRec) {
58
            ++$GLOBALS['TSFE']->recordRegister[$originalRec];
59
            ++$tsfe->recordRegister[$originalRec];
59 60
        }
60 61

  
61 62
        $tables = isset($conf['tables.']) ? $this->cObj->stdWrap($conf['tables'], $conf['tables.']) : $conf['tables'];
......
92 93
                    // Perform overlays if necessary (records coming from category collections are already overlaid)
93 94
                    if ($source) {
94 95
                        // Versioning preview
95
                        $GLOBALS['TSFE']->sys_page->versionOL($val['table'], $row);
96
                        $tsfe->sys_page->versionOL($val['table'], $row);
96 97
                        // Language overlay
97
                        if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
98
                        if (is_array($row) && $tsfe->sys_language_contentOL) {
98 99
                            if ($val['table'] === 'pages') {
99
                                $row = $GLOBALS['TSFE']->sys_page->getPageOverlay($row);
100
                                $row = $tsfe->sys_page->getPageOverlay($row);
100 101
                            } else {
101
                                $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($val['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
102
                                $fallbackChain = NULL;
103
                                if (isset($conf['languageFallbackChain'])) {
104
                                    $fallbackChain = GeneralUtility::intExplode(',', $conf['languageFallbackChain']);
105
                                }
106

  
107
                                $pageLanguageBinding = !isset($conf['respectPageLanguageBinding']) || (int)$conf['respectPageLanguageBinding'] !== '0';
108

  
109
                                $row = $tsfe->sys_page->getRecordOverlayWithFallback(
110
                                    $val['table'], $row, NULL, NULL, $fallbackChain, $pageLanguageBinding
111
                                );
102 112
                            }
103 113
                        }
104 114
                    }
......
108 118
                        if (!$dontCheckPid) {
109 119
                            $row = $this->cObj->checkPid($row['pid']) ? $row : '';
110 120
                        }
111
                        if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'] . ':' . $val['id']]) {
121
                        if ($row && !$tsfe->recordRegister[($val['table'] . ':' . $val['id'])]) {
112 122
                            $renderObjName = $conf['conf.'][$val['table']] ?: '<' . $val['table'];
113 123
                            $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.' . $val['table'] : '';
114 124
                            $renderObjConf = $conf['conf.'][$val['table'] . '.'];
115 125
                            $this->cObj->currentRecordNumber++;
116 126
                            $cObj->parentRecordNumber = $this->cObj->currentRecordNumber;
117
                            $GLOBALS['TSFE']->currentRecord = $val['table'] . ':' . $val['id'];
127
                            $tsfe->currentRecord = $val['table'] . ':' . $val['id'];
118 128
                            $this->cObj->lastChanged($row['tstamp']);
119 129
                            $cObj->start($row, $val['table']);
120 130
                            $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
......
132 142
            $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
133 143
        }
134 144
        // Restore
135
        $GLOBALS['TSFE']->currentRecord = $originalRec;
145
        $tsfe->currentRecord = $originalRec;
136 146
        if ($originalRec) {
137 147
            --$GLOBALS['TSFE']->recordRegister[$originalRec];
138 148
        }
......
230 240
    {
231 241
        return GeneralUtility::makeInstance(TimeTracker::class);
232 242
    }
243

  
244
    /**
245
     * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
246
     */
247
    protected function getTypoScriptFrontendController() {
248
        return $GLOBALS['TSFE'];
249
    }
233 250
}
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
574 574
     */
575 575
    public $sys_language_content = 0;
576 576

  
577
    /**
578
     * Contains the prioritized language fallback chain
579
     *
580
     * @var array
581
     */
582
    public $languageFallbackChain = [];
583

  
584
    /**
585
     * Contains the prioritized language fallback chain for the current page
586
     *
587
     * @var array
588
     */
589
    public $languageFallbackChainWithPageLanguageBinding = [];
590

  
577 591
    /**
578 592
     * Site content overlay flag; If set - and sys_language_content is > 0 - ,
579 593
     * records selected will try to look for a translation pointing to their uid. (If
......
2590 2604
        // Get values from TypoScript:
2591 2605
        $this->sys_language_uid = ($this->sys_language_content = (int)$this->config['config']['sys_language_uid']);
2592 2606
        list($this->sys_language_mode, $sys_language_content) = GeneralUtility::trimExplode(';', $this->config['config']['sys_language_mode']);
2607
        $languageFallbackChain = GeneralUtility::intExplode(',', $this->config['config']['languageFallbackChain']);
2593 2608
        $this->sys_language_contentOL = $this->config['config']['sys_language_overlay'];
2594 2609
        // If sys_language_uid is set to another language than default:
2595 2610
        if ($this->sys_language_uid > 0) {
......
2611 2626
                                $this->pageNotFoundAndExit('Page is not available in the requested language (strict).');
2612 2627
                                break;
2613 2628
                            case 'content_fallback':
2614
                                // Setting content uid (but leaving the sys_language_uid) when a content_fallback
2615
                                // value was found.
2616
                                $fallBackOrder = GeneralUtility::trimExplode(',', $sys_language_content);
2617
                                foreach ($fallBackOrder as $orderValue) {
2618
                                    if ($orderValue === '0' || $orderValue === '') {
2619
                                        $this->sys_language_content = 0;
2629
                                // default is to fallback to default language
2630
                                $this->sys_language_content = 0;
2631
                                foreach ($languageFallbackChain as $languageId) {
2632
                                    // break the language chain if the current language is selected
2633
                                    if ($languageId === 0) {
2620 2634
                                        break;
2621 2635
                                    }
2622
                                    if (MathUtility::canBeInterpretedAsInteger($orderValue) && !empty($this->sys_page->getPageOverlay($this->id, (int)$orderValue))) {
2623
                                        $this->sys_language_content = (int)$orderValue;
2624
                                        break;
2636
                                    // ignore current and invalid language ids
2637
                                    if ($this->sys_language_uid === $languageId || $languageId < 0) {
2638
                                        continue;
2625 2639
                                    }
2626
                                    if ($orderValue === 'pageNotFound') {
2627
                                        // The existing fallbacks have not been found, but instead of continuing
2628
                                        // page rendering with default language, a "page not found" message should be shown
2629
                                        // instead.
2630
                                        $this->pageNotFoundAndExit('Page is not available in the requested language (fallbacks did not apply).');
2640
                                    $pageOverlay = $this->sys_page->getPageOverlay($this->id, $languageId);
2641
                                    if (!empty($pageOverlay)) {
2642
                                        // Setting content uid (but leaving the sys_language_uid)
2643
                                        $this->sys_language_content = $languageId;
2644
                                        // overlay page with existing page overlay
2645
                                        $this->page = array_merge($this->page, $pageOverlay);
2646
                                        break;
2631 2647
                                    }
2632 2648
                                }
2633 2649
                                break;
......
2641 2657
                    }
2642 2658
                }
2643 2659
            } else {
2644
                // Setting sys_language if an overlay record was found (which it is only if a language is used)
2645
                $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid);
2660
                // overlay page with existing page overlay
2661
                $this->page = array_merge($this->page, $olRec);
2662
            }
2663
            // calculate the language fallback chains
2664
            if ($this->sys_language_mode === 'content_fallback') {
2665
                foreach ($languageFallbackChain as $languageId) {
2666
                    // ignore current and invalid language ids
2667
                    if ($this->sys_language_uid === $languageId || $languageId < 0) {
2668
                        continue;
2669
                    }
2670
                    $this->languageFallbackChain[] = $languageId;
2671
                    if ($languageId === 0 || count($this->sys_page->getPageOverlay($this->id, $languageId))) {
2672
                        $this->languageFallbackChainWithPageLanguageBinding[] = $languageId;
2673
                    }
2674
                }
2646 2675
            }
2647 2676
        }
2648 2677
        // Setting sys_language_uid inside sys-page:
2649 2678
        $this->sys_page->sys_language_uid = $this->sys_language_uid;
2650
        // If default translation is not available:
2651
        if ((!$this->sys_language_uid || !$this->sys_language_content) && GeneralUtility::hideIfDefaultLanguage($this->page['l18n_cfg'])) {
2679
        // If default translation is not to be selected
2680
        if ($this->page['l18n_cfg']&1 && !($this->sys_language_uid && $this->sys_language_content)) {
2652 2681
            $message = 'Page is not available in default language.';
2653 2682
            GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
2654 2683
            $this->pageNotFoundAndExit($message);
typo3/sysext/frontend/Classes/Page/PageRepository.php
28 28
use TYPO3\CMS\Core\Utility\HttpUtility;
29 29
use TYPO3\CMS\Core\Utility\RootlineUtility;
30 30
use TYPO3\CMS\Core\Versioning\VersionState;
31
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
31 32

  
32 33
/**
33 34
 * Page functions, a lot of sql/pages-related functions
......
430 431
            return [];
431 432
        }
432 433
        // Initialize:
434
        $noSpecialLanguageRequested = false;
433 435
        if ($lUid < 0) {
436
            $noSpecialLanguageRequested = true;
434 437
            $lUid = $this->sys_language_uid;
435 438
        }
436 439
        $row = null;
......
460 463
                    $page_ids[] = $origPage;
461 464
                }
462 465
            }
466

  
467
            $languages = [$lUid];
468
            if ($noSpecialLanguageRequested) {
469
                $languages = array_unique(array_merge(
470
                    [$lUid],
471
                    $this->getTypoScriptFrontendController()->languageFallbackChain,
472
                    [$this->getTypoScriptFrontendController()->sys_language_content]
473
                ));
474
            }
475

  
463 476
            // NOTE regarding the query restrictions
464 477
            // Currently the showHiddenRecords of TSFE set will allow
465 478
            // pages_language_overlay records to be selected as they are
......
477 490
                        'pid',
478 491
                        $queryBuilder->createNamedParameter($page_ids, Connection::PARAM_INT_ARRAY)
479 492
                    ),
480
                    $queryBuilder->expr()->eq(
493
                    $queryBuilder->expr()->in(
481 494
                        'sys_language_uid',
482
                        $queryBuilder->createNamedParameter($lUid, \PDO::PARAM_INT)
495
                        $queryBuilder->createNamedParameter($languages, Connection::PARAM_INT_ARRAY)
483 496
                    )
484 497
                )
485 498
                ->execute();
......
522 535
    }
523 536

  
524 537
    /**
525
     * Creates language-overlay for records in general (where translation is found
526
     * in records from the same table)
538
     * Creates a language overlay for records stored inside tables which contain the
539
     * translation information themselves. In addition to getRecordOverlay this method
540
     * also checks for specified content language fallbacks and includes them.
527 541
     *
528 542
     * @param string $table Table name
529
     * @param array $row Record to overlay. Must contain uid, pid and $table]['ctrl']['languageField']
543
     * @param array $row Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
530 544
     * @param int $sys_language_content Pointer to the sys_language uid for content on the site.
531 545
     * @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned  un-translated but unset (and return value is FALSE)
546
     * @param array|NULL $fallbackList ordered fallback list of language ids
547
     * @param bool $pageLanguageBinding use page language binding for the language fallback chain (only used if fallbackList is NULL)
548
     * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return NULL if no translation is found.
532 549
     * @throws \UnexpectedValueException
533
     * @return mixed Returns the input record, possibly overlaid with a translation.  But if $OLmode is "hideNonTranslated" then it will return FALSE if no translation is found.
534 550
     */
535
    public function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '')
551
    public function getRecordOverlayWithFallback(
552
        $table,
553
        $row,
554
        $sys_language_content = null,
555
        $OLmode = null,
556
        $fallbackList = null,
557
        $pageLanguageBinding = true
558
    ) {
559
        $tsfe = $this->getTypoScriptFrontendController();
560
        $sys_language_content = $sys_language_content !== null ? $sys_language_content : $tsfe->sys_language_content;
561
        $OLmode = $OLmode !== null ? $OLmode: $tsfe->sys_language_contentOL;
562
        if ($fallbackList === null) {
563
            $fallbackList = $tsfe->languageFallbackChainWithPageLanguageBinding;
564
            if (!$pageLanguageBinding) {
565
                $fallbackList = $tsfe->languageFallbackChain;
566
            }
567
        }
568

  
569
        $record = $this->getRecordOverlayWithoutFallback($table, $row, $sys_language_content, $OLmode);
570
        if (!is_array($record) || !isset($record['_LOCALIZED_UID'])) {
571
            if ($sys_language_content && $OLmode !== 'hideNonTranslated' && !empty($fallbackList)) {
572
                foreach ($fallbackList as $fallbackId) {
573
                    $fallbackId = (int)$fallbackId;
574
                    if ($fallbackId === 0) {
575
                        break;
576
                    }
577

  
578
                    $record = $this->getRecordOverlayWithoutFallback($table, $row, $fallbackId, $OLmode);
579
                    if (isset($record['_LOCALIZED_UID']) && is_array($record)) {
580
                        break;
581
                    }
582
                }
583
            }
584
        }
585
        return $record;
586
    }
587

  
588
    /**
589
     * Creates a language overlay for records stored inside tables which contain the
590
     * translation information themselves.
591
     *
592
     *
593
     * @param string $table Table name the record comes from
594
     * @param array $row Record to overlay. Must contain the columns uid, pid and $TCA[$table]['ctrl']['languageField']
595
     * @param int $sys_language_content Pointer to the sys_language uid to use for content.
596
     * @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned translated but unset (and return value is FALSE)
597
     * @throws \InvalidArgumentException
598
     * @throws \UnexpectedValueException
599
     * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return NULL if no translation is found.
600
     */
601
    public function getRecordOverlayWithoutFallback($table, $row, $sys_language_content, $OLmode = '')
536 602
    {
537 603
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'])) {
538 604
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] as $classRef) {
......
629 695
        return $row;
630 696
    }
631 697

  
698
    /**
699
     * Creates a language overlay for records stored inside tables which contain the
700
     * translation information themselves.
701
     *
702
     *
703
     * @param string $table Table name the record comes from
704
     * @param array $row Record to overlay. Must contain the columns uid, pid and $TCA[$table]['ctrl']['languageField']
705
     * @param int $sys_language_content Pointer to the sys_language uid to use for content.
706
     * @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned translated but unset (and return value is FALSE)
707
     * @throws \InvalidArgumentException
708
     * @throws \UnexpectedValueException
709
     * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return NULL if no translation is found.
710
     */
711
    public function getRecordOverlayWithoutFallback2($table, $row, $sys_language_content, $OLmode) {
712
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'])) {
713
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] as $classRef) {
714
                $hookObject = GeneralUtility::getUserObj($classRef);
715
                if (!$hookObject instanceof PageRepositoryGetRecordOverlayHookInterface) {
716
                    throw new \UnexpectedValueException('$hookObject must implement interface ' . PageRepositoryGetRecordOverlayHookInterface::class, 1269881658);
717
                }
718
                $hookObject->getRecordOverlay_preProcess($table, $row, $sys_language_content, $OLmode, $this);
719
            }
720
        }
721
        if ($row['uid'] > 0 && ($row['pid'] > 0 || in_array($table, $this->tableNamesAllowedOnRootLevel, true))) {
722
            if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
723
                if (!$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable']) {
724
                    // Will not be able to work with other tables (Just didn't implement it yet;
725
                    // Requires a scan over all tables [ctrl] part for first FIND the table that
726
                    // carries localization information for this table (which could even be more
727
                    // than a single table) and then use that. Could be implemented, but obviously
728
                    // takes a little more....) Will try to overlay a record only if the
729
                    // sys_language_content value is larger than zero.
730
                    if ($sys_language_content > 0) {
731
                        // Must be default language or [All], otherwise no overlaying:
732
                        if ($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) {
733
                            // Select overlay record:
734
                            $res = $this->getDatabaseConnection()->exec_SELECTquery('*', $table, 'pid=' . (int)$row['pid'] . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$sys_language_content . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$row['uid'] . $this->enableFields($table), '', '', '1');
735
                            $olrow = $this->getDatabaseConnection()->sql_fetch_assoc($res);
736
                            $this->getDatabaseConnection()->sql_free_result($res);
737
                            $this->versionOL($table, $olrow);
738
                            // Merge record content by traversing all fields:
739
                            if (is_array($olrow)) {
740
                                if (isset($olrow['_ORIG_uid'])) {
741
                                    $row['_ORIG_uid'] = $olrow['_ORIG_uid'];
742
                                }
743
                                if (isset($olrow['_ORIG_pid'])) {
744
                                    $row['_ORIG_pid'] = $olrow['_ORIG_pid'];
745
                                }
746
                                foreach ($row as $fN => $fV) {
747
                                    if ($fN !== 'uid' && $fN !== 'pid' && isset($olrow[$fN])) {
748
                                        if ($this->shouldFieldBeOverlaid($table, $fN, $olrow[$fN])) {
749
                                            $row[$fN] = $olrow[$fN];
750
                                        }
751
                                    } elseif ($fN === 'uid') {
752
                                        $row['_LOCALIZED_UID'] = $olrow['uid'];
753
                                    }
754
                                }
755
                            } elseif ($OLmode === 'hideNonTranslated' && (int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === 0) {
756
                                // Unset, if non-translated records should be hidden. ONLY done if the source
757
                                // record really is default language and not [All] in which case it is allowed.
758
                                $row = null;
759
                            }
760
                        } elseif ($sys_language_content != $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]) {
761
                            $row = null;
762
                        }
763
                    } else {
764
                        // When default language is displayed, we never want to return a record carrying
765
                        // another language!
766
                        if ($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
767
                            $row = null;
768
                        }
769
                    }
770
                }
771
            }
772
        }
773
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'])) {
774
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getRecordOverlay'] as $classRef) {
775
                $hookObject = GeneralUtility::getUserObj($classRef);
776
                if (!$hookObject instanceof PageRepositoryGetRecordOverlayHookInterface) {
777
                    throw new \UnexpectedValueException('$hookObject must implement interface ' . PageRepositoryGetRecordOverlayHookInterface::class, 1269881659);
778
                }
779
                $hookObject->getRecordOverlay_postProcess($table, $row, $sys_language_content, $OLmode, $this);
780
            }
781
        }
782

  
783
        return $row;
784
    }
785

  
786
    /**
787
     * Creates language-overlay for records in general (where translation is found
788
     * in records from the same table)
789
     *
790
     * @param string $table Table name
791
     * @param array $row Record to overlay. Must contain uid, pid and $table]['ctrl']['languageField']
792
     * @param int $sys_language_content Pointer to the sys_language uid for content on the site.
793
     * @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned  un-translated but unset (and return value is FALSE)
794
     * @throws \UnexpectedValueException
795
     * @return mixed Returns the input record, possibly overlaid with a translation.  But if $OLmode is "hideNonTranslated" then it will return FALSE if no translation is found.
796
     * @deprecated
797
     */
798
    public function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '') {
799
        GeneralUtility::logDeprecatedFunction();
800
        return $this->getRecordOverlayWithoutFallback($table, $row, $sys_language_content, $OLmode);
801
    }
802

  
632 803
    /************************************************
633 804
     *
634 805
     * Page related: Menu, Domain record, Root line
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
132 132
        $GLOBALS['TSFE']->sys_language_contentOL = 1;
133 133
        $this->subject->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(['_PAGES_OVERLAY_LANGUAGE' => 1]));
134 134
        $this->subject->parent_cObj->expects($this->once())->method('exec_getQuery')->willReturn($statementProphet->reveal());
135
        $this->subject->sys_page->expects($this->once())->method('getRecordOverlay')->will($this->returnValue(['uid' => 0, 'header' => 'OVERLAID']));
135
        $this->subject->sys_page->expects($this->once())->method('getRecordOverlayWithFallback')->will($this->returnValue(['uid' => 0, 'header' => 'OVERLAID']));
136 136
        $result = $this->subject->_call('sectionIndex', 'field');
137 137
        $this->assertEquals($result[0]['title'], 'OVERLAID');
138 138
    }