diff --git a/cake/libs/configure.php b/cake/libs/configure.php index ab424c3edfc..4e0ca6f5ce5 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 @@ function write($config, $value = null) { } if (isset($config['debug'])) { + $reporting = 0; if ($_this->debug) { - error_reporting(E_ALL & ~E_DEPRECATED); - + 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 (!class_exists('Debugger')) { - require LIBS . 'debugger.php'; - } + 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 @@ function read($var = 'debug') { $_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 528f7195704..c2ece8a6a49 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -144,6 +144,8 @@ function testWrite() { * @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 @@ function testSetErrorReportingLevel() { $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 *