diff --git a/dev/Debug.php b/dev/Debug.php index 3a4efefc6..273059aeb 100644 --- a/dev/Debug.php +++ b/dev/Debug.php @@ -5,12 +5,10 @@ * Attaches custom methods to the default error handling hooks * in PHP. Currently, two levels of error are supported: * + * - Notice * - Warning * - Error * - * Notice level errors are currently unsupported, and will be passed - * directly to the normal PHP error output. - * * Uncaught exceptions are currently passed to the debug * reporter as standard PHP errors. * @@ -19,7 +17,6 @@ * class documentation. * * @todo add support for user defined config: Debug::die_on_notice(true | false) - * @todo add appropriate handling for E_NOTICE and E_USER_NOTICE levels * @todo better way of figuring out the error context to display in highlighted source * * @package sapphire @@ -196,6 +193,26 @@ class Debug { set_exception_handler('exceptionHandler'); } + static function noticeHandler($errno, $errstr, $errfile, $errline, $errcontext) { + if(error_reporting() == 0) return; + + // Send out the error details to the logger for writing + SSLog::log( + array( + 'errno' => $errno, + 'errstr' => $errstr, + 'errfile' => $errfile, + 'errline' => $errline, + 'errcontext' => $errcontext + ), + SSLog::NOTICE + ); + + if(Director::isDev()) { + self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Notice"); + } + } + /** * Handle a non-fatal warning error thrown by PHP interpreter. * @@ -628,12 +645,15 @@ function errorHandler($errno, $errstr, $errfile, $errline) { Debug::fatalHandler($errno, $errstr, $errfile, $errline, null); break; - case E_NOTICE: case E_WARNING: case E_CORE_WARNING: case E_USER_WARNING: Debug::warningHandler($errno, $errstr, $errfile, $errline, null); break; + case E_NOTICE: + case E_USER_NOTICE: + Debug::noticeHandler($errno, $errstr, $errfile, $errline, null); + break; } } diff --git a/dev/DebugView.php b/dev/DebugView.php index 9a5545801..d2440d5d9 100644 --- a/dev/DebugView.php +++ b/dev/DebugView.php @@ -26,6 +26,10 @@ class DebugView { 'title' => 'Notice', 'class' => 'notice' ), + E_USER_NOTICE => array( + 'title' => 'Notice', + 'class' => 'notice' + ), E_CORE_ERROR => array( 'title' => 'Core Error', 'class' => 'error' diff --git a/dev/SSBacktrace.php b/dev/SSBacktrace.php index d850b41a5..469658665 100644 --- a/dev/SSBacktrace.php +++ b/dev/SSBacktrace.php @@ -37,6 +37,7 @@ class SSBacktrace { 'CliDebugView->writeTrace', 'Debug::emailError', 'Debug::warningHandler', + 'Debug::noticeHandler', 'Debug::fatalHandler', 'errorHandler', 'Debug::showError', diff --git a/dev/SSLogErrorEmailFormatter.php b/dev/SSLogErrorEmailFormatter.php index 7837eeda1..78d1b3f03 100644 --- a/dev/SSLogErrorEmailFormatter.php +++ b/dev/SSLogErrorEmailFormatter.php @@ -10,11 +10,19 @@ require_once 'Zend/Log/Formatter/Interface.php'; class SSLogErrorEmailFormatter implements Zend_Log_Formatter_Interface { public function format($event) { - $errorType = ($event['priorityName'] == 'WARN') ? 'Warning' : 'Error'; - if($event['priorityName'] == 'WARN') { - $colour = "orange"; - } else { - $colour = "red"; + switch($event['priorityName']) { + case 'ERR': + $errorType = 'Error'; + $colour = 'red'; + break; + case 'WARN': + $errorType = 'Warning'; + $colour = 'warning'; + break; + case 'NOTICE': + $errorType = 'Notice'; + $colour = 'grey'; + break; } if(!is_array($event['message'])) {