[4] Include custom fatal page so that any post-processing, alerting, can happen as designed #35352
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My bad again. Sorry.
Summary of Changes
In Joomla 3 fatal errors (like cant connect to the db) are shows like this
Error
- yup thats it, one word in black on a white blank page.In Joomla 4 we moved to handling fatal errors with the Symfony Error Handler (not my work), and more importantly we (I) implemented a custom template after changes were merged upstream in Symfony.
Joomla 4.0.0 was the first product to ever be published with a custom Symfony Error Page 🎉
This gave us the (now almost infamous) red page of death when a fatal error happens on the frontend of Joomla 4.
(Many people are seeing this - when upgrading to Joomla 4 without reading, and with incompatible plugins - thats its job after all! )
One of the principles that was implemented was the introduction of a
fatal-error.custom.php
file that template designers could drop intotemplates/system/
which could be used instead of the red screen of death - for the purposes (as documented infatal.php
) of:However, as implemented prior to this PR, any PHP code in the
fatal-error.custom.php
would not actually parse!!!! Doh! as 8000 the content of the file was loaded withfile_get_contents
and thenecho
to the response.This PR fixes the invalid implementation by correctly including the file, allowing any PHP to parse (This allows the developer to use PHP to call a remote service, display dynamic data, send an email alerting apps, Sentry.io etc)
Testing Instructions
/templates/system/fatal-error.custom.php
file with<?php echo 'Hello World';
as its content.<?php echo 'Hello World';
in unparsed and just output as the responseHello World
For bonus points, note you can do:
and get an output of
HELLO WORLD500Whoops, looks like something went wrong.
this proves that the original status are being passed through for custom template designers to style/place however they like.For more bonus points in
configuration.php
set$debug = true;
and see the Symfony Debug Trace - just to show you what the red page of death is actually "hiding" from your site visitors!REMEMBER this "red page of death" is a FATAL ERROR page, its NOT MEANT to ever be shown in real life. ITS NOT THE ERROR PAGE, its a FATAL error page. The lowest of the low. Again this is the reason the custom template is NOT in the
template/my_template/
folder but available to be placed in thetemplates/system/
folder - because at the FATAL ERROR state it cannot be assumed that any part of Joomla is available (Eg: a Factory or application or db connection)Actual result BEFORE applying this Pull Request
The content of the
fatal-error.custom.php
would be rendered in the source of the response - even if it was PHP.PHP would not be parsed, just outputted.
Expected result AFTER applying this Pull Request
The PHP in
fatal-error.custom.php
is now parsed, triggered, and runs as expected and as originally designed for this feature.Custom template developers can go mad and replace the "Red Screen Of Death" with something else... and can include PHP which is parsed.
Documentation Changes Required
None. Joomla 4 is so new I doubt anyone has noticed this is even possible yet :)
ref:
@Webdongle https://forum.joomla.org/viewtopic.php?f=810&t=987965&p=3637277#p3637277