Skip to content

Commit

Permalink
Removing support for DEBUG constant. Use Configure::write('debug', 2)…
Browse files Browse the repository at this point in the history
… instead.

Adding 'log' interaction to error reporting settings controlled by Configure::write().
  • Loading branch information
markstory committed Sep 8, 2009
1 parent 90b6272 commit cac0948
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
33 changes: 16 additions & 17 deletions cake/libs/configure.php
Expand Up @@ -42,7 +42,7 @@ class Configure extends Object {
* @var integer * @var integer
* @access public * @access public
*/ */
var $debug = null; var $debug = 0;


/** /**
* Returns a singleton instance of the Configure class. * Returns a singleton instance of the Configure class.
Expand Down Expand Up @@ -106,24 +106,30 @@ function write($config, $value = null) {
} }


if (isset($config['debug'])) { if (isset($config['debug'])) {
$reporting = 0;
if ($_this->debug) { 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')) { if (function_exists('ini_set')) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
} }
} elseif (function_exists('ini_set')) {
ini_set('display_errors', 0);
}


if (!class_exists('Debugger')) { if (isset($_this->log) && $_this->log) {
require LIBS . 'debugger.php';
}
if (!class_exists('CakeLog')) { if (!class_exists('CakeLog')) {
require LIBS . 'cake_log.php'; require LIBS . 'cake_log.php';
} }
Configure::write('log', LOG_NOTICE); if (is_integer($_this->log) && !$_this->debug) {
} else { $reporting = $_this->log;
error_reporting(0); } else {
Configure::write('log', LOG_NOTICE); $reporting = E_ALL & ~E_DEPRECATED;
}
} }
error_reporting($reporting);
} }
} }


Expand All @@ -143,13 +149,6 @@ function read($var = 'debug') {
$_this =& Configure::getInstance(); $_this =& Configure::getInstance();


if ($var === 'debug') { if ($var === 'debug') {
if (!isset($_this->debug)) {
if (defined('DEBUG')) {
$_this->debug = DEBUG;
} else {
$_this->debug = 0;
}
}
return $_this->debug; return $_this->debug;
} }


Expand Down
24 changes: 24 additions & 0 deletions cake/tests/cases/libs/configure.test.php
Expand Up @@ -144,6 +144,8 @@ function testWrite() {
* @return void * @return void
**/ **/
function testSetErrorReportingLevel() { function testSetErrorReportingLevel() {
Configure::write('log', false);

Configure::write('debug', 0); Configure::write('debug', 0);
$result = ini_get('error_reporting'); $result = ini_get('error_reporting');
$this->assertEqual($result, 0); $this->assertEqual($result, 0);
Expand All @@ -160,6 +162,28 @@ function testSetErrorReportingLevel() {
$this->assertEqual($result, 0); $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 * testDelete method
* *
Expand Down

0 comments on commit cac0948

Please sign in to comment.