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

[5.0] Custom Error Pages - new feature #40597

Merged
merged 2 commits into from
Jun 26, 2023
Merged

Conversation

brianteeman
Copy link
Contributor

@brianteeman brianteeman commented May 15, 2023

Summary of Changes

Adds a module position to the error.php page of cassiopeia so that you can customise the 404 page without having to change language strings or asking the user to modify the error.php (which they will lose on update)

This is fully backwards compatible as the existing error page text is displayed if there is no module. If debug is enabled then the debug information is still displayed

In theory the error.php is used by joomla for all error codes so this PR is able to display a specific module for each error code.

Testing Instructions

Apply the PR
Create a new module (custom html is probably the most useful) and publish in the new position error-404
Go to a fake page on your site and you will see the 404 page with your new module
Unpublish the module and repeat and you will see the original 404 page with the language strings

Original 404

image

Example 404 AFTER applying this Pull Request and creating a module

image

image

If accepted then I will create a guided tour for this and post-installation message

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

cc @crystalenka @HLeithner @alexandreelise

@brianteeman brianteeman requested a review from chmst as a code owner May 15, 2023 10:37
@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-5.0-dev labels May 15, 2023
@rdeutz
Copy link
Contributor

rdeutz commented May 15, 2023

Nice.

Just one idea: could we have a generic error position error-default to have a non technical error message by default. (Can be done in a different PR OFC)

@brianteeman
Copy link
Contributor Author

Nice.

Just one idea: could we have a generic error position error-default to have a non technical error message by default. (Can be done in a different PR OFC)

My feeling was that is what the existing text is for and that will be displayed when it is not a 404 (or 403 if you have a module for that as well.)

I'm not sure what other error codes ever make it to the error.php file

@ManuelHu
Copy link
Contributor

First, this is great 👍

My feeling was that is what the existing text is for and that will be displayed when it is not a 404 (or 403 if you have a module for that as well.)

But the existing text also contains guidance that - more or less - only applies to 404/403 errors. (i.e. anything about "out-of-date bookmarks" or "mistyped addresses", "no access"...)
If the 404/403 errors are customized, this then should also be possible with the remaining errors...

Another note: as the module is dependant on the error code, creating a module in position error-0 should actually catch most usual PHP Errors and Exceptions (i.e. those which do not set an error code).

@brianteeman
Copy link
Contributor Author

If the 404/403 errors are customized, this then should also be possible with the remaining errors...

It is possible with this code already. I just did not add a pre-defined module for every possible error code.

Another note: as the module is dependant on the error code, creating a module in position error-0 should actually catch most usual PHP Errors and Exceptions (i.e. those which do not set an error code).

Are you sure that the error.php is used in those scenario? This pr is NOT changing the way that errors are handled. It ONLY allows for changes in the infornmation dispplayed

@ManuelHu
Copy link
Contributor

It is possible with this code already. I just did not add a pre-defined module for every possible error code.

I know. My comment was just a case for the addition of a default/fallback error module. (so that you don't have to define a rather hacky error-0 module) Apart from that, it is not guaranteed that the code is always 0 for all generic/non HTTP error exceptions...

Are you sure that the error.php is used in those scenario? This pr is NOT changing the way that errors are handled. It ONLY allows for changes in the infornmation dispplayed

I am quite sure that - at least in J!3 - the frontend error.php was also called for generic exceptions or sometimes even PHP Errors. I did not 'test' this yet with J!4 (read, I never had a site that broken yet :-)

@brianteeman
Copy link
Contributor Author

When you are sure that its true in j4 ...

@ManuelHu
Copy link
Contributor

ManuelHu commented Jun 7, 2023

I just verified in J!4.3: When an Exception is thrown somewhere (e.g. in a template override), the error.php is called and $this->error->getCode() == 0.

@HLeithner HLeithner merged commit b2843f9 into joomla:5.0-dev Jun 26, 2023
3 checks passed
@HLeithner
Copy link
Member

thanks, would you be so kind a create a pr for the system template too?

I think documentation at manual.joomla.org would also make sense

@brianteeman
Copy link
Contributor Author

THANK YOU!!!

I will create the docs later today

@HLeithner HLeithner added this to the Joomla! 5.0 milestone Jun 26, 2023
@brianteeman brianteeman deleted the errorpages branch June 26, 2023 07:59
heelc29 added a commit to heelc29/joomla that referenced this pull request Aug 2, 2023
heelc29 added a commit to heelc29/joomla that referenced this pull request Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants