mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing support for DEBUG constant. Use Configure::write('debug', 2) instead.
Adding 'log' interaction to error reporting settings controlled by Configure::write().
This commit is contained in:
parent
90b6272a14
commit
cac09481ac
2 changed files with 41 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue