? Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
25 Jan 2020

Summary of Changes

@wilsonge I found an issue in #27470 ?
You have set HtmlErrorRenderer as ExceptionHandler that incorrect of course, because it a rendered not a handler ?.
I have fixed it here.

And because ErrorHandler may show whole error detail on production environment I have disable it by default, a full trace may be enabled by enabling debug or changing "display errors" option in global config

Additionally I have made changes to Joomla\ExceptionHandler, now it will use global ExceptionHandler as "last resort", which allow to do a better debugging, now it also pre-save a full trace of both exceptions, instead of old useless "Error" message.

Testing Instructions

First step:
To test need to emulate a "heavy crash", for this add 2 exception to the cassiopeia template:
First in index.php : throw new Exception('The main error!');
Second at top of error.php: throw new Exception('The error of the error!');

Then go to the site, you should see the error:
screen 2020-01-25 12 36 26 600x218

Second step:
Go to administrator global configuration and set "Display Error" to "maximum", or enable "Debug"
Then go to the site, you should see detailed information about all exceptions that occurred:
(click on little +)
screen 2020-01-25 12 40 55 1060x322

@mbabker please have a look also

avatar Fedik Fedik - open - 25 Jan 2020
avatar Fedik Fedik - change - 25 Jan 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Jan 2020
Category Administration Libraries
avatar Fedik Fedik - change - 25 Jan 2020
The description was changed
avatar Fedik Fedik - edited - 25 Jan 2020
282400c 25 Jan 2020 avatar Fedik phpcs
avatar Fedik Fedik - change - 25 Jan 2020
Labels Added: ?
18febb5 25 Jan 2020 avatar Fedik typo
avatar Fedik Fedik - change - 25 Jan 2020
The description was changed
avatar Fedik Fedik - edited - 25 Jan 2020
avatar Fedik Fedik - change - 25 Jan 2020
The description was changed
avatar Fedik Fedik - edited - 25 Jan 2020
avatar mbabker
mbabker - comment - 25 Jan 2020

No more commented constants that have to be edited in code to access. Use the system configuration for this or don’t introduce a new behavior.

Also, do not judge the use based solely on naming. This may very well be the correct way to configure the component, or the rendering logic may require additional adjustments to do right.

avatar Fedik
Fedik - comment - 25 Jan 2020

Use the system configuration for this or don’t introduce a new behavior.

Yeah, but I have no idea here, configuration.php not possible to use at this point.
It may be existing constant in git repository, and removed while release. But this also may be confusing.

Also, do not judge the use based solely on naming.

What do you mean? I not very understood.

avatar mbabker
mbabker - comment - 25 Jan 2020

And because ErrorHandler may show whole error detail on production environment I have disable it by default

If you reviewed the component then you’d know that by default it is in a state where only an error message is printed, there is no need for extra configuration except to enable additional debug information.

To me this PR comes across as someone not really understanding the code attempting to make changes for the sake of change. The only tangible benefit is the rethrow if rendering the error page fails but that code is convoluted and impossible to actually follow what the intended behaviors are.

avatar mbabker
mbabker - comment - 25 Jan 2020

Use the system configuration for this or don’t introduce a new behavior.

Yeah, but I have no idea here, configuration.php not possible to use at this point.
It may be existing constant in git repository, and removed while release. But this also may be confusing.

I’m saying don’t introduce a new conditionally defined constant that someone has to edit a file to enable. Use the configuration. The reason I never enabled debug output is because of the problem you noted, adding new constants doesn’t fix the bootstrapping problem (because ultimately the issue here is things are not loaded in a usable order, load it all in the right order and the need for a conditional constant goes away).

Also, do not judge the use based solely on naming.

What do you mean? I not very understood.

You’re saying it’s wrong based solely on the fact the class is named “renderer”. I’m saying that might not be the case.

avatar Fedik
Fedik - comment - 25 Jan 2020

If you reviewed the component then you’d know that by default it is in a state where only an error message is printed, there is no need for extra configuration except to enable additional debug information.

I am actually disabling it, because it enabled by default:
https://github.com/symfony/error-handler/blob/06443075f4274d908705191f3777d8e5a69357a7/ErrorHandler.php#L89-L91

You’re saying it’s wrong based solely on the fact the class is named “renderer”. I’m saying that might not be the case.

I did not made this conclusion by reviewing the name, that would be not very smart. ?
I found it while debugging.
In fact you cannot set custom Rendered:
https://github.com/symfony/error-handler/blob/06443075f4274d908705191f3777d8e5a69357a7/ErrorHandler.php#L698-L713
To do this we need to make own Handler class that extend symfone handler, if I right understood.

avatar mbabker
mbabker - comment - 25 Jan 2020

If you reviewed the component then you’d know that by default it is in a state where only an error message is printed, there is no need for extra configuration except to enable additional debug information.

I am actually disabling it, because it enabled by default:
https://github.com/symfony/error-handler/blob/06443075f4274d908705191f3777d8e5a69357a7/ErrorHandler.php#L89-L91

Then it should respect the error handling configuration, not be an all or nothing thing or based on a hidden configuration flag. Which still means the load order needs to be fixed.

avatar Fedik Fedik - change - 26 Jan 2020
The description was changed
avatar Fedik Fedik - edited - 26 Jan 2020
avatar Fedik
Fedik - comment - 26 Jan 2020

I have made Error Handler configurable, without additional constant. Should be better now.
Testing instruction also updated.

avatar Fedik Fedik - change - 26 Jan 2020
The description was changed
avatar Fedik Fedik - edited - 26 Jan 2020
avatar wilsonge
wilsonge - comment - 26 Jan 2020

You have set HtmlErrorRenderer as ExceptionHandler that incorrect of course, because it a rendered not a handler ?.

That's not really true? https://github.com/symfony/symfony/blob/master/src/Symfony/Component/ErrorHandler/ErrorHandler.php#L149 The renderer is still the default exception handler in your code - you just aren't calling it explicitely ;)

However I think largely the changes your making here are on the right lines - although I agree with Michael to an extent - the changes you are making to the exception handler are really confusing to me :D There has to be a cleaner way of dealing with it?

avatar Fedik
Fedik - comment - 26 Jan 2020

The renderer is still the default exception handler in your code - you just aren't calling it explicitely

That confusing part ?
Rendered cannot be as handler.
The code does not explode, because setExceptionHandler allow callback with the same argument as Renderer::render (\Throwable $exception)
in the same way we can set ClassNotFoundErrorEnhancer as handler and it will not explode, but it does not do anything usefull.
Look at the source, it just return FlattenException https://github.com/symfony/symfony/blob/524ee7acb676d3e2109c8f4afb8e9fa60711ee4f/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php#L67 , and does not produce any output.
The output going there https://github.com/symfony/symfony/blob/524ee7acb676d3e2109c8f4afb8e9fa60711ee4f/src/Symfony/Component/ErrorHandler/ErrorHandler.php#L692-L713 where the HtmlErrorRenderer or CliErrorRenderer are actualy used ;)

There has to be a cleaner way of dealing with it?

You mean nested exception? I think it okay, Learning something new it is okay :)
Here a bit about https://translate.google.com/translate?hl=en&sl=auto&tl=en&u=https%3A%2F%2Fqiita.com%2Fmpyw%2Fitems%2F7f5a9fe6472f38352d96
It seems old feature that not much know, but there many such things.
And the behavior covered by PHP test

avatar Fedik
Fedik - comment - 26 Jan 2020

here is a better explanation https://nikic.github.io/2017/04/14/PHP-7-Virtual-machine.html#finally-handling
read "Finally handling" section

Throw from finally: If there is a backed-up exception in the FAST_CALL temporary, chain it as the previous exception of the thrown one. Continue bubbling the exception up to the next try/catch/finally.

avatar Fedik
Fedik - comment - 26 Jan 2020

And I believe it part of this RFC (Implemented) https://wiki.php.net/rfc/finally wich has the same test files, unfortunately they lost in history.

avatar Fedik
Fedik - comment - 27 Jan 2020

I have updated comments, and use server error_reporting for initial set up.

avatar Fedik
Fedik - comment - 9 Feb 2020

Can we have some errors here please? I meant a tests ?

avatar wilsonge wilsonge - change - 20 Mar 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-03-20 17:21:22
Closed_By wilsonge
avatar wilsonge wilsonge - close - 20 Mar 2020
avatar wilsonge wilsonge - merge - 20 Mar 2020
avatar wilsonge
wilsonge - comment - 20 Mar 2020

Merging this on review for now. Seems to have addressed @mbabker 's comments and I think he knows more of this than I clearly do :)

Add a Comment

Login with GitHub to post a comment