Skip to content

Commit

Permalink
Ignore errorHandler if warning suppressor (@command()) is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Dec 2, 2010
1 parent ffaec10 commit aa0bad9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cake/console/libs/console_error_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public static function handleException($exception) {
* @return void
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null) {
if (error_reporting() === 0) {
return;
}
$stderr = self::getStderr();
list($name, $log) = self::_mapErrorCode($code);
$message = sprintf(__('%s in [%s, line %s]'), $description, $file, $line);
Expand Down
3 changes: 3 additions & 0 deletions cake/libs/error/error_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public static function handleException(Exception $exception) {
* @return boolean true if error was handled
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null) {
if (error_reporting() === 0) {
return false;
}
$errorConfig = Configure::read('Error');
list($error, $log) = self::_mapErrorCode($code);

Expand Down
15 changes: 15 additions & 0 deletions cake/tests/cases/libs/error/error_handler.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ function testErrorMapping($error, $expected) {
$this->assertPattern('/<b>' . $expected . '<\/b>/', $result);
}

/**
* test error prepended by @
*
* @return void
*/
function testErrorSuppressed() {
set_error_handler('ErrorHandler::handleError');
$this->_restoreError = true;

ob_start();
@include 'invalid.file';
$result = ob_get_clean();
$this->assertTrue(empty($result));
}

/**
* Test that errors go into CakeLog when debug = 0.
*
Expand Down

0 comments on commit aa0bad9

Please sign in to comment.