Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Drupal seems to return a 200 OK HTTP status code for exception errors thrown by _drupal_exception_handler(). This doesn't seem right, since that causes the error page to be cached, for example in Varnish. Is there a reason for this behaviour? I couldn't find an issue for the bug, but it has been mentioned on the support forum at https://www.drupal.org/node/2598442.
Comment | File | Size | Author |
---|---|---|---|
#6 | drupal-500_exception_on_exception-12221055-6.patch | 779 bytes | iamEAP |
Comments
Comment #2
ZeiP CreditAttribution: ZeiP at Avoltus Oy commentedAttached is a simple patch to return 500 Internal Server Error instead.
Comment #3
cilefen CreditAttribution: cilefen commentedDoes Drupal 8 do the same thing?
Comment #4
iamEAP CreditAttribution: iamEAP commentedRan into this as well. One common way you might hit this is if you have a cache class that throws an exception in the page cache bootstrap phase (e.g. Redis cannot connect or server goes away). This will cause the error logger to attempt to load the maintenance theme, which will attempt to load modules/themes, which will eventually result in a cache_get() attempt (which will throw another exception).
Moving back to needs work as you would want to set response code to 500 regardless of whether or not errors can be displayed.
Comment #5
iamEAP CreditAttribution: iamEAP commentedPatch to account for that, with explanation text.
Comment #6
iamEAP CreditAttribution: iamEAP commentedUpdated patch with minor change to status text to better align with HTTP standards.
Comment #7
cilefen CreditAttribution: cilefen commentedComment #8
cilefen CreditAttribution: cilefen commentedComment #9
SylvainM CreditAttribution: SylvainM at Axess Open Web Services commentedTested and it works great, thanks!
Comment #10
tobybellwood CreditAttribution: tobybellwood at govCMS (Australian Government Department of Finance) for govCMS (Australian Government Department of Finance) commentedWe've just deployed this patch into production for all of our sites (we're using docker with Redis pods, and they'll generate 500's on respawn which were being occasionally cached at the edge as 200's before this patch).
Given the relatively low complexity of the patch and large upside in these scenarios, we'd support this patch making it's way into core.
Comment #11
PolHi all,
I would like to push this patch forward.
Do you know if it's already in D8?
Thanks.
Comment #12
PolI mostly sure that this is already in D8, see core/includes/errors.inc, around line 265.
Comment #13
PolComment #14
PolComment #15
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedRTBC + 1, let get this in -- it's a good stepping stone (incidentally I also ran into this yesterday)
Comment #17
PolFixed! Thanks all !