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

Ensure error message screen is shown instead of safemode when a regular error happens while rendering a view #20213

Merged
merged 3 commits into from Jan 15, 2023

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Jan 13, 2023

This can be reproduced via a URL like /index.php?&module=Widgetize&action=iframe&moduleToWidgetize=Dashboard&actionToWidgetize=index&idSite=2&period=week&date=yesterday&updated=2

Currently, on Cloud would see a screen like below while on On-Premise they would see a similar "safemode" screenshot
image

As in above case it is a user input error, and not a twig error, we should still show the regular exception error like below:
image

This way, the Cloud team also won't be emailed every time there is a wrong user input and the user will know what needs changing.

Review

This can be reproduced via a URL like `/index.php?&module=Widgetize&action=iframe&moduleToWidgetize=Dashboard&actionToWidgetize=index&idSite=2&period=week&date=yesterday&updated=2`
@@ -181,8 +181,14 @@ public function dispatch($module = null, $action = null, $parameters = null)
*/
Piwik::postEvent('User.isNotAuthorized', array($exception), $pending = true);
} catch (\Twig\Error\RuntimeError $e) {
echo $this->generateSafeModeOutputFromException($e);
exit;
if ($e->getPrevious() && !$e->getPrevious() instanceof \Twig\Error\RuntimeError) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem was that see screenshot the actual exception would always be converted to a runtime exception
image
Even if it was actually not in twig but part of an event or so.

@tsteur tsteur added the Needs Review PRs that need a code review label Jan 13, 2023
@tsteur tsteur modified the milestones: 4.13.1, 4.13.2 Jan 13, 2023
@tsteur tsteur changed the title Ensure error message screen is shown instead of safemode Ensure error message screen is shown instead of safemode when a regular error happens while rendering a view Jan 13, 2023
Copy link
Contributor

@bx80 bx80 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bx80 bx80 merged commit 8507a33 into 4.x-dev Jan 15, 2023
@bx80 bx80 deleted the errorscreen branch January 15, 2023 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants