Presently, Grawlix sends HTTP status code 200 OK even when displaying error pages. With this PR, it sends 404 headers whenever:
A comic page cannot be shown because it doesn't exist or isn't public yet
A static page cannot be found (most invalid URLs lead to this).
The page info for a given static page cannot be found (very rare, should only be due to errors in the database)
All the other page content is displayed as before, all that's different is the header.
I also commented out a check that sends a 200 header because it was never true anyway.
The 404 header (mostly) is sent in one place: GrlxPage2::buildPage(). The scenarios that cause it just set a statusCode property that's checked in that method. This means that it should be smooth to add this to any other error pages I may have missed, as well as adding headers for other error codes if the need arises.
The one exception is the 404 sent when page info cannot be found. I had to send it there as well because afterwards PHP just die()s.
The header is not sent in any case where Grawlix has no explicit error handling, such as requests to /comic/non-numeric-ID (Grawlix just shows the base page template with no content in these cases). These errors are very unlikely, but probably worth looking into handling at a later date.
Presently, Grawlix sends HTTP status code
200 OK
even when displaying error pages. With this PR, it sends 404 headers whenever:All the other page content is displayed as before, all that's different is the header.
I also commented out a check that sends a 200 header because it was never true anyway.
The 404 header (mostly) is sent in one place: GrlxPage2::buildPage(). The scenarios that cause it just set a
statusCode
property that's checked in that method. This means that it should be smooth to add this to any other error pages I may have missed, as well as adding headers for other error codes if the need arises. The one exception is the 404 sent when page info cannot be found. I had to send it there as well because afterwards PHP justdie()
s.The header is not sent in any case where Grawlix has no explicit error handling, such as requests to
/comic/non-numeric-ID
(Grawlix just shows the base page template with no content in these cases). These errors are very unlikely, but probably worth looking into handling at a later date.