Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Exception when "<v:page.rootline>" is used and pageUid doesn't exist #1905

Closed
Oktopuce opened this issue Apr 23, 2024 · 2 comments
Closed

Comments

@Oktopuce
Copy link
Contributor

Oktopuce commented Apr 23, 2024

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:

  1. 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.

  1. Display the page with this code in frontend
  2. 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 [];
}
@Oktopuce Oktopuce changed the title BUG: Exception when "<v:page.rootline" is used and pageUid doesn't exist BUG: Exception when "<v:page.rootline>" is used and pageUid doesn't exist Apr 23, 2024
Oktopuce added a commit to Oktopuce/vhs that referenced this issue Apr 23, 2024
Oktopuce added a commit to Oktopuce/vhs that referenced this issue Apr 23, 2024
Oktopuce added a commit to Oktopuce/vhs that referenced this issue Apr 23, 2024
Oktopuce added a commit to Oktopuce/vhs that referenced this issue Apr 23, 2024
@NamelessCoder
Copy link
Member

I would argue that in this case it's desirable to get an exception and undesirable to suppress all warning/error output when a non-existing page is passed. Otherwise you're just left clueless about why you get an empty root line.

I suggest using v:try around the root line extracting ViewHelper - this also lets you render an alternative when this exception is raised.

@NamelessCoder
Copy link
Member

I made the decision to reject this - it's undesirable to have this API suppress warnings about unreadable pages. See #1906 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants