From cac09481ac9965ef6dd3fca50a1f04074c20cf65 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Sep 2009 23:28:50 -0400 Subject: [PATCH] Removing support for DEBUG constant. Use Configure::write('debug', 2) instead. Adding 'log' interaction to error reporting settings controlled by Configure::write(). --- cake/libs/configure.php | 35 ++++++++++++------------ cake/tests/cases/libs/configure.test.php | 24 ++++++++++++++++ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index ab424c3ed..4e0ca6f5c 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -42,7 +42,7 @@ class Configure extends Object { * @var integer * @access public */ - var $debug = null; + var $debug = 0; /** * Returns a singleton instance of the Configure class. @@ -106,24 +106,30 @@ class Configure extends Object { } if (isset($config['debug'])) { + $reporting = 0; if ($_this->debug) { - error_reporting(E_ALL & ~E_DEPRECATED); - - if (function_exists('ini_set')) { - ini_set('display_errors', 1); - } - if (!class_exists('Debugger')) { require LIBS . 'debugger.php'; } + $reporting = E_ALL & ~E_DEPRECATED; + if (function_exists('ini_set')) { + ini_set('display_errors', 1); + } + } elseif (function_exists('ini_set')) { + ini_set('display_errors', 0); + } + + if (isset($_this->log) && $_this->log) { if (!class_exists('CakeLog')) { require LIBS . 'cake_log.php'; } - Configure::write('log', LOG_NOTICE); - } else { - error_reporting(0); - Configure::write('log', LOG_NOTICE); + if (is_integer($_this->log) && !$_this->debug) { + $reporting = $_this->log; + } else { + $reporting = E_ALL & ~E_DEPRECATED; + } } + error_reporting($reporting); } } @@ -143,13 +149,6 @@ class Configure extends Object { $_this =& Configure::getInstance(); if ($var === 'debug') { - if (!isset($_this->debug)) { - if (defined('DEBUG')) { - $_this->debug = DEBUG; - } else { - $_this->debug = 0; - } - } return $_this->debug; } diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 528f71957..c2ece8a6a 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -144,6 +144,8 @@ class ConfigureTest extends CakeTestCase { * @return void **/ function testSetErrorReportingLevel() { + Configure::write('log', false); + Configure::write('debug', 0); $result = ini_get('error_reporting'); $this->assertEqual($result, 0); @@ -160,6 +162,28 @@ class ConfigureTest extends CakeTestCase { $this->assertEqual($result, 0); } +/** + * test that log and debug configure values interact well. + * + * @return void + **/ + function testInteractionOfDebugAndLog() { + Configure::write('log', false); + + Configure::write('debug', 0); + $this->assertEqual(ini_get('error_reporting'), 0); + $this->assertEqual(ini_get('display_errors'), 0); + + Configure::write('log', E_WARNING); + Configure::write('debug', 0); + $this->assertEqual(ini_get('error_reporting'), E_WARNING); + $this->assertEqual(ini_get('display_errors'), 0); + + Configure::write('debug', 2); + $this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED); + $this->assertEqual(ini_get('display_errors'), 1); + } + /** * testDelete method *