summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-05 17:06:18 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-05 17:06:18 +0000
commit57d35b7fb18619cb68e405f586471ea0ac1453fe (patch)
tree8aa00621a010ca8f522185543b5a43c648b9bffa /includes
parentdc1af5e2909258358348a17b17a3f87850396e32 (diff)
downloadbrdo-57d35b7fb18619cb68e405f586471ea0ac1453fe.tar.gz
brdo-57d35b7fb18619cb68e405f586471ea0ac1453fe.tar.bz2
- Patch #243532 by Damien Tournoud et al: catch notices, warnings and fatal errors during testing. Woop, woop.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc18
1 files changed, 17 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc
index df2b8e1d2..34b40fbac 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -615,6 +615,7 @@ function _drupal_error_handler($error_level, $message, $filename, $line, $contex
E_RECOVERABLE_ERROR => 'Recoverable fatal error'
);
$backtrace = debug_backtrace();
+
// We treat recoverable errors as fatal.
_drupal_log_error(isset($types[$error_level]) ? $types[$error_level] : 'Unknown error', $message, $backtrace, $error_level == E_RECOVERABLE_ERROR);
}
@@ -673,10 +674,25 @@ function _drupal_log_error($type, $message, $backtrace, $fatal) {
// Do it early because drupal_set_message() triggers an init_theme().
if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
unset($GLOBALS['theme']);
- define('MAINTENANCE_MODE', 'error');
+ if (!defined('MAINTENANCE_MODE')) {
+ define('MAINTENANCE_MODE', 'error');
+ }
drupal_maintenance_theme();
}
+ // When running inside the testing framework, we relay the errors
+ // to the tested site by the way of HTTP headers.
+ if (preg_match("/^simpletest\d+/", $GLOBALS['db_prefix']) && !headers_sent() && !defined('SIMPLETEST_DONT_COLLECT_ERRORS')) {
+ static $number = 0;
+ $assertion = array(
+ $message,
+ $type,
+ $caller
+ );
+ header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
+ $number++;
+ }
+
// Force display of error messages in update.php.
if (variable_get('error_level', 1) == 1 || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) {
drupal_set_message(t('@type: %message in %function (line %line of %file).', array('@type' => $type, '%message' => $message, '%function' => $caller['function'], '%line' => $caller['line'], '%file' => $caller['file'])), 'error');