Skip to content
This repository
Browse code

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
  • Loading branch information...
commit b64b1219c4ebc8c46d51d8a35c8ef0ed85a16acd 1 parent 5fd1926
Mark Story authored May 28, 2011
6  cake/libs/cake_log.php
@@ -288,5 +288,9 @@ function handleError($code, $description, $file = null, $line = null, $context =
288 288
 
289 289
 if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) {
290 290
 	$cakeLog =& CakeLog::getInstance();
291  
-	set_error_handler(array($cakeLog, 'handleError'));
  291
+	if (PHP5) {
  292
+		set_error_handler(array($cakeLog, 'handleError'), error_reporting());
  293
+	} else {
  294
+		set_error_handler(array($cakeLog, 'handleError'));
  295
+	}
292 296
 }
9  cake/libs/configure.php
@@ -123,14 +123,15 @@ function write($config, $value = null) {
123 123
 			}
124 124
 
125 125
 			if (isset($_this->log) && $_this->log) {
126  
-				if (!class_exists('CakeLog')) {
127  
-					require LIBS . 'cake_log.php';
128  
-				}
129 126
 				if (is_integer($_this->log) && !$_this->debug) {
130 127
 					$reporting = $_this->log;
131 128
 				} else {
132 129
 					$reporting = E_ALL & ~E_DEPRECATED;
133 130
 				}
  131
+				error_reporting($reporting);
  132
+				if (!class_exists('CakeLog')) {
  133
+					require LIBS . 'cake_log.php';
  134
+				}
134 135
 			}
135 136
 			error_reporting($reporting);
136 137
 		}
@@ -1317,4 +1318,4 @@ function __destruct() {
1317 1318
 			Cache::write('object_map', $this->__objects, '_cake_core_');
1318 1319
 		}
1319 1320
 	}
1320  
-}
  1321
+}

0 notes on commit b64b121

Please sign in to comment.
Something went wrong with that request. Please try again.