vhs
vhs copied to clipboard
BUG: Exception when "<v:page.rootline>" is used and pageUid doesn't exist
I have checked that the bug exists in the dev-development
branch
Yes.
I have checked that there are no already open issues or recently closed issues about this bug Yes.
Describe the bug
When you're trying to get the root line of a page that doesn't exist, a PageNotFoundException
exception is thrown:
(1/1) #1343589451 TYPO3\CMS\Core\Exception\Page\PageNotFoundException
To Reproduce Steps to reproduce the behavior:
- Insert in a Fluid Template, a bloc like this:
<v:page.rootline pageUid="{linkNotInDb}" as="theRootLine">
...
</v:page.rootline>
with {linkNotInDb}
having a page Uid that doesn't exist in DB.
- Display the page with this code in frontend
- See exception
Expected behavior
No PageNotFoundException
exception should be thrown
Additional context
In file vhs/Classes/Service/PageService.php, method getRootLine() the call to $rootLineUtility->get()
must be surrounded by try{} catch()
try {
/** @var RootlineUtility $rootLineUtility */
$rootLineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageUid);
$rootline = $rootLineUtility->get();
} catch (PageNotFoundException $e) {
return [];
}