Fixing CakeLog::handleError() being called too often.

Adding a PHP5 conditional, so custom error handlers are not called
for errors not in the configured masking.
Fixes #1735
This commit is contained in:
mark_story 2011-05-28 13:59:56 -04:00
parent 5fd19266ba
commit b64b1219c4
2 changed files with 10 additions and 5 deletions

View file

@ -288,5 +288,9 @@ class CakeLog {
if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) { if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) {
$cakeLog =& CakeLog::getInstance(); $cakeLog =& CakeLog::getInstance();
set_error_handler(array($cakeLog, 'handleError')); if (PHP5) {
set_error_handler(array($cakeLog, 'handleError'), error_reporting());
} else {
set_error_handler(array($cakeLog, 'handleError'));
}
} }

View file

@ -123,14 +123,15 @@ class Configure extends Object {
} }
if (isset($_this->log) && $_this->log) { if (isset($_this->log) && $_this->log) {
if (!class_exists('CakeLog')) {
require LIBS . 'cake_log.php';
}
if (is_integer($_this->log) && !$_this->debug) { if (is_integer($_this->log) && !$_this->debug) {
$reporting = $_this->log; $reporting = $_this->log;
} else { } else {
$reporting = E_ALL & ~E_DEPRECATED; $reporting = E_ALL & ~E_DEPRECATED;
} }
error_reporting($reporting);
if (!class_exists('CakeLog')) {
require LIBS . 'cake_log.php';
}
} }
error_reporting($reporting); error_reporting($reporting);
} }
@ -1317,4 +1318,4 @@ class App extends Object {
Cache::write('object_map', $this->__objects, '_cake_core_'); Cache::write('object_map', $this->__objects, '_cake_core_');
} }
} }
} }