When a developer uses e.g. the hook_post_action module to submit a new node and this fails with an exception, it gets silently unreported as the error message will not be shown to the user because the HTTP 302 and the Location header set by the node module are still in effect.

This patch removes eventual Location headers and sets HTTP 500 error code so the user can see the exception.

CommentFileSizeAuthor
drupal-core-shutdownexception.patch749 bytesmschuster91
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mschuster91 created an issue. See original summary.

cilefen’s picture

Status: Active » Needs review
cilefen’s picture

Version: 7.39 » 7.x-dev
+++ b/includes/bootstrap.inc
@@ -3473,6 +3473,10 @@ function _drupal_shutdown_function() {
+    // In case this exception is e.g. caused by an error in a shutdown function involving saving of a node,
+    // unset the Location header so the user can actually see it. Also, set a HTTP 500 error code.
+    header_remove("Location");

I realize the existing comment below this chunk exceeds 80 columns but it is the code standard to wrap inline comments at 80 columns.

Also:

Please check if this is an issue with Drupal 8. If so, it must be fixed there first according to the backport policy.