Skip to content

Commit

Permalink
Fixing CakeLog::handleError() being called too often.
Browse files Browse the repository at this point in the history
Adding a PHP5 conditional, so custom error handlers are not called
for errors not in the configured masking.
Fixes #1735
  • Loading branch information
markstory committed May 28, 2011
1 parent 5fd1926 commit b64b121
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion cake/libs/cake_log.php
Expand Up @@ -288,5 +288,9 @@ function handleError($code, $description, $file = null, $line = null, $context =


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'));
}
} }
9 changes: 5 additions & 4 deletions cake/libs/configure.php
Expand Up @@ -123,14 +123,15 @@ function write($config, $value = null) {
} }


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);
} }
Expand Down Expand Up @@ -1317,4 +1318,4 @@ function __destruct() {
Cache::write('object_map', $this->__objects, '_cake_core_'); Cache::write('object_map', $this->__objects, '_cake_core_');
} }
} }
} }

0 comments on commit b64b121

Please sign in to comment.