Skip to content

Commit

Permalink
[BUGFIX] handle localizations with un-available tsfe more gracefully
Browse files Browse the repository at this point in the history
Given the following scenario:
- non-localized root page for multi-language site
- below this root page is a localized folder
- inside that localized folder are localized record to index

Since TypoScriptFrontendController is not initialized for sys_folder
page records, it'll walk up to the parent page and try to initialize
TypoScriptFrontendController for it. However, this isn't possible in
the given scenario because the page isn't localized into all languages.
Tsfe::getTsfeByPageIdAndLanguageId() returns null in this case, which
triggers a NullPointerException when getLanguageOverlay() is called on
it. When the NPE is thrown none of the localizations of the item will
be indexed, even though some could have been successfully indexed.

This change checks aborts the operation when the specific
TypoScriptFrontendController for the item is null, which causes queue
items for which TypoScriptFrontendController could not be initialized
to not get indexed.
  • Loading branch information
adamkoppede authored and dkd-kaehm committed Oct 13, 2023
1 parent 9749512 commit bbdda0c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Classes/IndexQueue/Indexer.php
Expand Up @@ -259,9 +259,14 @@ protected function getItemRecordOverlayed(Item $item, int $language): ?array

$pidToUse = $this->getPageIdOfItem($item);

return GeneralUtility::makeInstance(Tsfe::class)
->getTsfeByPageIdAndLanguageId($pidToUse, $language, $item->getRootPageUid())
->sys_page->getLanguageOverlay($item->getType(), $itemRecord);
$globalTsfe = GeneralUtility::makeInstance(Tsfe::class);
$specializedTsfe = $globalTsfe->getTsfeByPageIdAndLanguageId($pidToUse, $language, $item->getRootPageUid());

if ($specializedTsfe === null) {
return null;
}

return $specializedTsfe->sys_page->getLanguageOverlay($item->getType(), $itemRecord);
}

protected function isAFreeContentModeItemRecord(Item $item): bool
Expand Down

0 comments on commit bbdda0c

Please sign in to comment.