mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Make default PHP error handler fatal
This commit is contained in:
parent
3e57cc069e
commit
454412905c
@ -526,8 +526,9 @@ function exceptionHandler($exception) {
|
||||
|
||||
/**
|
||||
* Generic callback to catch standard PHP runtime errors thrown by the interpreter
|
||||
* or manually triggered with the user_error function.
|
||||
* Caution: The error levels default to E_ALL is the site is in dev-mode (set in main.php).
|
||||
* or manually triggered with the user_error function. Any unknown error codes are treated as
|
||||
* fatal errors.
|
||||
* Caution: The error levels default to E_ALL if the site is in dev-mode (set in main.php).
|
||||
*
|
||||
* @ignore
|
||||
* @param int $errno
|
||||
@ -537,21 +538,23 @@ function exceptionHandler($exception) {
|
||||
*/
|
||||
function errorHandler($errno, $errstr, $errfile, $errline) {
|
||||
switch($errno) {
|
||||
case E_ERROR:
|
||||
case E_CORE_ERROR:
|
||||
case E_USER_ERROR:
|
||||
return Debug::fatalHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
|
||||
|
||||
case E_WARNING:
|
||||
case E_CORE_WARNING:
|
||||
case E_USER_WARNING:
|
||||
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:
|
||||
return Debug::noticeHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
|
||||
|
||||
case E_WARNING:
|
||||
case E_CORE_WARNING:
|
||||
case E_USER_WARNING:
|
||||
case E_RECOVERABLE_ERROR:
|
||||
return Debug::warningHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
|
||||
|
||||
case E_ERROR:
|
||||
case E_CORE_ERROR:
|
||||
case E_USER_ERROR:
|
||||
default:
|
||||
return Debug::fatalHandler($errno, $errstr, $errfile, $errline, debug_backtrace());
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,18 @@ class DebugView extends Object {
|
||||
E_STRICT => array(
|
||||
'title' => 'Strict Notice',
|
||||
'class' => 'notice'
|
||||
),
|
||||
E_RECOVERABLE_ERROR => array(
|
||||
'title' => 'Recoverable Error',
|
||||
'class' => 'warning'
|
||||
)
|
||||
);
|
||||
|
||||
protected static $unknown_error = array(
|
||||
'title' => 'Unknown Error',
|
||||
'class' => 'error'
|
||||
);
|
||||
|
||||
/**
|
||||
* Generate breadcrumb links to the URL path being displayed
|
||||
*
|
||||
@ -133,7 +142,7 @@ class DebugView extends Object {
|
||||
* Write information about the error to the screen
|
||||
*/
|
||||
public function writeError($httpRequest, $errno, $errstr, $errfile, $errline, $errcontext) {
|
||||
$errorType = self::$error_types[$errno];
|
||||
$errorType = isset(self::$error_types[$errno]) ? self::$error_types[$errno] : self::$unknown_error;
|
||||
$httpRequestEnt = htmlentities($httpRequest, ENT_COMPAT, 'UTF-8');
|
||||
echo '<div class="info ' . $errorType['class'] . '">';
|
||||
echo "<h1>[" . $errorType['title'] . '] ' . strip_tags($errstr) . "</h1>";
|
||||
|
Loading…
Reference in New Issue
Block a user