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
Fix EZP-23913: Override legacy fatal error message #1138
Conversation
If you see https://github.com/ezsystems/ezpublish-legacy/pull/1138/files?diff=split You will notice that I just create one if statement that checks for the existence of such variable. |
No BC break +1 |
+1 We love this solution! |
+1 |
Shouldn't you also examine the setting for |
|
||
[ErrorSettings] | ||
# Allow the default eZ Publish 500 error message to be overridden | ||
# FatalErrorHandler=CustomFatalErrorHandlerClass::FatalErrorHandlerFunction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing empty line at the end of the file.
+1 |
just a thought. as long as we already have a dedicate error.ini file, couldn't we move that setting there too? |
@crevillo sounds like a good idea |
I have updated the code and now it should a setting defined in the error.ini and also check if the method is callable. |
echo "<b>Fatal error</b>: The web server did not finish its request<br/>"; | ||
if ( ini_get('display_errors') == 1 ) | ||
$errorINI = eZINI::instance( 'error.ini' ); | ||
if( $errorINI->hasVariable( 'ErrorSettings-kernel', 'FatalErrorHandler' ) && is_callable( $errorINI->variable( 'ErrorSettings-kernel', 'FatalErrorHandler' ) ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: space after the if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Carlos, I am not sure about what you mean, there is no trailing spaces there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm sayin that the line should be like if (
instead of if(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks.
Updated code, fixed if statement. |
+1. useful thing!. |
+/-0 this won't work with siteaccess settings, will only be global, because of how early this is registered (it has to be early, so I'm not saying it should be moved). |
Do you think it should be necessary to put a note in the .ini comment? Something like:
|
Something like that would help a bit. |
I confirmed the limitation and put a note about it. |
I am not sure why CI build failed, the current code shouldn't be executed at all because it will require that the ini variable to be defined and also the class::method exists, also about the code itself, I checked eZExecution and it adds the fatal error handlers like this:
And call them like this:
So, it should work, as long as I am passing a string and call_user_func accepts strings. |
Checked https://travis-ci.org/ezsystems/ezpublish-legacy/jobs/47844272
Seems like an unrelated error is affecting the Travis CI build? |
+1 with the principle since it is backward compatible. We could even have a default implement in the LegacyBundle ;-) Nitpick: given that the modified code doesn't use any variable from the laaaarge constructor's scope, you could move this to a protected method. It wouldn't hurt, and would make this step self-contained. |
Hi Bertrand Do you recommend a name for the method? |
I have updated the code and moved it to its own method. |
registerFatalErrorHandler ? |
I have seem that setupFatalErrorHandler might be a better option because I have seen some code using setup, is this pull request good enough to be merged? |
How do we handle improvement PR on legacy now ? ping @andrerom @bdunogier |
We on the 'eZ Publish Pull Request Team' want this feature merged so it can be included in the next 'eZ Publish 5.x Community Build' (which is being driven now by community support). So we are strongly compelled to encourage this legacy improvement PR from mugo.ca to be merged. We can't 👍 enough this PR! |
So if everybody is still +1, I'll merge it ;) |
+1 here |
+1 Yes please and thank you :) |
I don't see anything wrong with it. What do you think, @andrerom ? |
Fix EZP-23913: Override legacy fatal error message
Thanks @thiagocamposviana |
The message "Fatal error: The web server did not finish its request" cannot be overridden in eZ Publish:
https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/private/classes/ezpkernelweb.php#L213
See more at: https://jira.ez.no/browse/EZP-23913
This pull request allows this to be overridden, the developer can now define a error.ini (only in global escope, ie, settings/override/error.ini.append.php) variable like:
[ErrorSettings-kernel]
FatalErrorHandler=CustomFatalErrorHandlerClass::FatalErrorHandlerFunction