Permalink
Browse files

Removing support for DEBUG constant. Use Configure::write('debug', 2)…

… instead.

Adding 'log' interaction to error reporting settings controlled by Configure::write().
  • Loading branch information...
1 parent 90b6272 commit cac09481ac9965ef6dd3fca50a1f04074c20cf65 @markstory markstory committed Sep 8, 2009
Showing with 40 additions and 17 deletions.
  1. +16 −17 cake/libs/configure.php
  2. +24 −0 cake/tests/cases/libs/configure.test.php
View
@@ -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;
}
@@ -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);
@@ -161,6 +163,28 @@ function testSetErrorReportingLevel() {
}
/**
+ * 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
*
* @access public

0 comments on commit cac0948

Please sign in to comment.