When the database is being updated (for example, when using drush sql-sync) exceptions are naturally thrown when Drupal tries to contact the database and doesn't find the proper tables.
On an exception, Drupal tries to write to the watchdog log. When dblog is enabled, a watchdog write causes a database write, which causes a second exception. In these cases, Drupal returns HTTP 200, since the drupal_http_header call that sets the 500 status is after the watchdog call. Lines 202-206 of includes/errors.inc:
watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
// Exception, execution stops
if ($fatal) {
drupal_add_http_header('Status', '500 Service unavailable (with message)');
}
Would swapping the watchdog call with the conditional fix this without causing any side-effects?
This can cause problems when the returned HTTP code is important. For example, when a machine (not a user with a browser) is requesting something, is fine if Drupal responds with an exception message, but the response code must be 500 so the client knows to discard the response data.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | drupal-http_200_on_exception-2317929-1-D7.patch | 675 bytes | colinmccabe |
Comments
Comment #1
colinmccabe commentedComment #2
colinmccabe commented