User tests: Successful: Unsuccessful:
Pull Request for Issue #45398.
set the error code on the HTTP response
this is similar to the other error renderes (i.e. copied from https://github.com/joomla/joomla-cms/blob/5.3-dev/libraries/src/Error/Renderer/JsonRenderer.php)
set a menu item that shows an article as the home menu item
2, open https://<your-site>/?format=feed
-- of course, this is not a useful feed link (I know that; thats the whole point.
see a response such as
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>404</code>
<message>View nicht gefunden [Name, Typ, Präfix]: article, feed, site</message>
</error>
the HTTP response status is 200
the HTTP response status (not the one listed as <code>404</code>
) is actually 404
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
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Title |
|
well, yes, if we assume that
setHeader
method)note: a similar check is not only implemented in JsonRenderer, but also in ErrorDocument
joomla-cms/libraries/src/Document/ErrorDocument.php
Lines 119 to 131 in 74e625d
also in the joomla-framework/application documentation:
https://github.com/joomla-framework/application/blob/e063a4a308729b930d853e29a9f7c303cac68629/README.md?plain=1#L54
However, this check is missing in other places. Also note, I am not an export in this (all of this just based on my code reviw of the last day), so I am not really sure what to decide here.
The instanceof check is fine, but I think ->setHeader('status', $error->getCode() < 400 ? 500 : $error->getCode());
would be enough. Or do you see an issue with it?
No, this should be equivalent in all typical cases. This very verbose code is just the same as already in the Json response, but I can certainly simplify the code.
Labels |
Added:
bug
PR-5.3-dev
|
I have tested this item ✅ successfully on fbc2426
I see the network response code change from 200 to 404 after applying the patch and the Firefox Browser Tools show a problem icon. So it works as described but I can't comment on the experts comments.
Not sure but is it not enough to add this single line in the function
\Joomla\CMS\Factory::getApplication()->setHeader('status', $error->getCode());