Permalink
Browse files

BUGFIX: Updated SilverStripe error handler so that log_errors still w…

…orks.
  • Loading branch information...
sminnee authored and chillu committed Mar 15, 2011
1 parent 82988d4 commit 6fcbad1a31519cdfeb0f2587100166097bba3833
Showing with 20 additions and 14 deletions.
  1. +20 −14 dev/Debug.php
View
@@ -213,6 +213,7 @@ public static function loadErrorHandlers() {
public static function noticeHandler($errno, $errstr, $errfile, $errline, $errcontext) {
if(error_reporting() == 0) return;
+ ini_set('display_errors', 0);
// Send out the error details to the logger for writing
SS_Log::log(
@@ -227,7 +228,9 @@ public static function noticeHandler($errno, $errstr, $errfile, $errline, $errco
);
if(Director::isDev()) {
- self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Notice");
+ return self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Notice");
+ } else {
+ return false;
}
}
@@ -242,8 +245,10 @@ public static function noticeHandler($errno, $errstr, $errfile, $errline, $errco
*/
public static function warningHandler($errno, $errstr, $errfile, $errline, $errcontext) {
if(error_reporting() == 0) return;
+ ini_set('display_errors', 0);
+
if(self::$send_warnings_to) {
- self::emailError(self::$send_warnings_to, $errno, $errstr, $errfile, $errline, $errcontext, "Warning");
+ return self::emailError(self::$send_warnings_to, $errno, $errstr, $errfile, $errline, $errcontext, "Warning");
}
// Send out the error details to the logger for writing
@@ -263,8 +268,10 @@ public static function warningHandler($errno, $errstr, $errfile, $errline, $errc
}
if(Director::isDev()) {
- self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Warning");
- }
+ return self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Warning");
+ } else {
+ return false;
+ }
}
/**
@@ -279,6 +286,8 @@ public static function warningHandler($errno, $errstr, $errfile, $errline, $errc
* @param unknown_type $errcontext
*/
public static function fatalHandler($errno, $errstr, $errfile, $errline, $errcontext) {
+ ini_set('display_errors', 0);
+
if(self::$send_errors_to) {
self::emailError(self::$send_errors_to, $errno, $errstr, $errfile, $errline, $errcontext, "Error");
}
@@ -300,11 +309,10 @@ public static function fatalHandler($errno, $errstr, $errfile, $errline, $errcon
}
if(Director::isDev() || Director::is_cli()) {
- self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Error");
+ return self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Error");
} else {
- self::friendlyError();
+ return self::friendlyError();
}
- exit(1);
}
/**
@@ -363,6 +371,7 @@ class_exists('Translatable') ? Translatable::get_current_locale() : null
$renderer->writeFooter();
}
}
+ return false;
}
/**
@@ -679,7 +688,7 @@ function exceptionHandler($exception) {
$file = $exception->getFile();
$line = $exception->getLine();
$context = $exception->getTrace();
- Debug::fatalHandler($errno, $message, $file, $line, $context);
+ return Debug::fatalHandler($errno, $message, $file, $line, $context);
}
/**
@@ -698,21 +707,18 @@ function errorHandler($errno, $errstr, $errfile, $errline) {
case E_ERROR:
case E_CORE_ERROR:
case E_USER_ERROR:
- Debug::fatalHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
- break;
+ return Debug::fatalHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
case E_WARNING:
case E_CORE_WARNING:
case E_USER_WARNING:
- Debug::warningHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
- break;
+ return Debug::warningHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
case E_NOTICE:
case E_USER_NOTICE:
case E_DEPRECATED:
case E_USER_DEPRECATED:
case E_STRICT:
- Debug::noticeHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
- break;
+ return Debug::noticeHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
}
}

0 comments on commit 6fcbad1

Please sign in to comment.