From 5d2cef268af5881c6c81ea1c22c5bab8d7f752c6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 11 Sep 2012 22:47:04 -0400 Subject: [PATCH] Make error handling use Configure again. --- App/Config/error.php | 18 ++++++++---------- App/Config/session.php | 7 +++---- lib/Cake/Core/Configure.php | 12 ++++++++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/App/Config/error.php b/App/Config/error.php index 54f67916bf3..7c1f25b000d 100644 --- a/App/Config/error.php +++ b/App/Config/error.php @@ -32,12 +32,12 @@ * * @see ErrorHandler for more information on error handling and configuration. */ - $error = array( + Configure::write('Error', [ 'handler' => 'Cake\Error\ErrorHandler::handleError', 'consoleHandler' => 'Cake\Console\ConsoleErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true - ); + ]); /** * Configure the Exception handler used for uncaught exceptions. By default, @@ -55,16 +55,14 @@ * * @see ErrorHandler for more information on exception handling and configuration. */ - $exception = array( + Configure::write('Exception', [ 'handler' => 'Cake\Error\ErrorHandler::handleException', 'consoleHandler' => 'Cake\Console\ConsoleErrorHandler::handleException', 'renderer' => 'Cake\Error\ExceptionRenderer', 'log' => true - ); + ]); - Configure::setErrorHandlers( - $error, - $exception - ); - - unset($error, $exception); +/** + * Once configured, set the error/exception handlers to PHP's default handlers. + */ + Configure::setErrorHandlers(); diff --git a/App/Config/session.php b/App/Config/session.php index bc1fc76ff91..160558fe5a9 100644 --- a/App/Config/session.php +++ b/App/Config/session.php @@ -14,7 +14,7 @@ */ namespace App\Config; -use Cake\Model\Datasource\Session; +use Cake\Core\Configure; /** * Session configuration. @@ -52,8 +52,7 @@ * * To use database sessions, run the app/Config/Schema/sessions.php schema using * the cake shell command: cake schema create Sessions - * */ - Session::config(array( + Configure::write('Session', [ 'defaults' => 'php' - )); + ]); diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 410bb6aecf0..19bf1e69185 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -348,15 +348,17 @@ public static function clear() { static::$_values = array(); return true; } + /** - * Set the error and exception handlers. + * Set the error and exception handlers using the native default handlers. + * + * Uses data already stored in Configure. * - * @param array $error The Error handling configuration. - * @param array $exception The exception handling configuration. * @return void */ - public static function setErrorHandlers($error, $exception) { + public static function setErrorHandlers() { $level = -1; + $error = static::read('Error'); if (isset($error['level'])) { error_reporting($error['level']); $level = $error['level']; @@ -364,8 +366,10 @@ public static function setErrorHandlers($error, $exception) { if (!empty($error['handler'])) { set_error_handler($error['handler'], $level); } + $exception = static::read('Exception'); if (!empty($exception['handler'])) { set_exception_handler($exception['handler']); } } + }