Skip to content

Commit

Permalink
Manage PageNotFoundException in getRootLine() method
Browse files Browse the repository at this point in the history
Correct this issue: #1905
  • Loading branch information
Oktopuce authored and Florian RIVAL committed Apr 23, 2024
1 parent 6c57bd8 commit 84e2e83
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Classes/Service/PageService.php
Expand Up @@ -11,6 +11,7 @@

use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Exception\Page\PageNotFoundException;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Type\Bitmask\PageTranslationVisibility;
Expand Down Expand Up @@ -79,9 +80,13 @@ public function getRootLine(
if (null === $pageUid) {
$pageUid = $GLOBALS['TSFE']->id;
}
/** @var RootlineUtility $rootLineUtility */
$rootLineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid);
$rootline = $rootLineUtility->get();
try {
/** @var RootlineUtility $rootLineUtility */
$rootLineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid);
$rootline = $rootLineUtility->get();
} catch (PageNotFoundException $e) {
return [];
}
if ($reverse) {
$rootline = array_reverse($rootline);
}
Expand Down

0 comments on commit 84e2e83

Please sign in to comment.