Project

General

Profile

Actions

Bug #93578

closed

getPagesOverlay in Page Repository ignores language specific fallback

Added by David Hedden over 3 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
Start date:
2021-02-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

Description

getPagesOverlay calls the function to get the language fallback chain with null as argument.
This will than return the current fallback chain, and not the appropriate for that language.
https://github.com/TYPO3/TYPO3.CMS/blob/298c3d4c400702c893bbe58503635cd2d905e340/typo3/sysext/frontend/Classes/Page/PageRepository.php#L562

An example to test this behavior is creating a language menu, the resulting available status is different depending on the current language.

Language Fallback Page is translated Expected status From default From de-ch
default Y Y Y Y
de Y Y Y Y
de-ch de X Y X Y
en X X X Y

Getting the fallback chain from the site entity in the request for that language fixes the issue.
But it depends on the request being correct, so fetching a page from another page tree would result in a wrong configuration.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #98303: Use PSR-14 Events in PageRepository for getLanguageOverlay functionalityClosedBenni Mack2022-09-08

Actions
Actions #1

Updated by Hannes Lau about 2 years ago

I can confirm the issue and I would like to submit a patch. Instead of getting the fallback chain from the current page and current language, we need to get the fallback chain from the requested page and requested overlay language.

Something along the lines of:

// PageRepository::getPagesOverlay
// …
$overlays = [];
// If language UID is different from zero, do overlay:
if ($languageUid) {
    $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
    foreach ($pagesInput as $origPage) {
        $pageUid = is_array($origPage) ? (int)($origPage['uid'] ?? 0) : (int)$origPage;
        $site = $siteFinder->getSiteByPageId($pageUid);
        $siteLanguage = $site->getLanguageById($languageUid);
        $languageAspect = LanguageAspectFactory::createFromSiteLanguage($siteLanguage);
        $languageUids = array_merge([$languageUid], $this->getLanguageFallbackChain($languageAspect));
        $additionalOverlays = $this->getPageOverlaysForLanguageUids([$pageUid], $languageUids);
        $overlays = array_merge($overlays, $additionalOverlays);
    }
}

There are two issues with this approach:
  • Unfortunately, the call to `$site->getLanguageById($languageUid)` leads to an endless loop via the RootlineUtility.
  • There might be a negative performance impact, as the pages do not get overlaid as bulk, but page by page. It might be more efficient to group the overlay queries by site and target language.
Actions #2

Updated by Hannes Lau about 2 years ago

I just realized that this may already have been dealt with in https://forge.typo3.org/issues/98303.

Actions #3

Updated by Oliver Hader about 2 years ago

  • Sprint Focus set to On Location Sprint
Actions #4

Updated by Benni Mack about 2 years ago

  • Related to Task #98303: Use PSR-14 Events in PageRepository for getLanguageOverlay functionality added
Actions #5

Updated by Benni Mack about 2 years ago

@hannes: Supercurious to see if you have a solution for this problem in v11 (or even 12).

Actions #6

Updated by Benni Mack over 1 year ago

Adding this here for future investigation: https://extensions.typo3.org/extension/mst_contentfallback

Actions #7

Updated by Benni Mack over 1 year ago

  • Sprint Focus deleted (On Location Sprint)
Actions #8

Updated by Benni Mack 12 months ago

  • Status changed from New to Needs Feedback

I added the multi-step fallback inside getLanguageOverlay() in PageRepository in v12. Can somebody verify if this problem is now solved for their use-cases?

Actions #9

Updated by David Hedden 11 months ago

Benni Mack wrote in #note-8:

I added the multi-step fallback inside getLanguageOverlay() in PageRepository in v12. Can somebody verify if this problem is now solved for their use-cases?

The example i stated in the issue is solved, verified it in 12.4.10-dev.

Actions #10

Updated by Benni Mack 10 months ago

  • Status changed from Needs Feedback to Closed

Thanks for the info, I will close this ticket then!

Actions

Also available in: Atom PDF