Ignore errorHandler if warning suppressor (@command()) is used.

This commit is contained in:
Juan Basso 2010-12-02 01:44:31 -02:00
parent ffaec10a7c
commit aa0bad9247
3 changed files with 21 additions and 0 deletions

View file

@ -70,6 +70,9 @@ class ConsoleErrorHandler extends ErrorHandler {
* @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);

View file

@ -135,6 +135,9 @@ class ErrorHandler {
* @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);

View file

@ -113,6 +113,21 @@ class ErrorHandlerTest extends CakeTestCase {
$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.
*