|
|
@ -1,23 +1,22 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
/** |
|
|
|
/** |
|
|
|
* This file contains the error handler application component. |
|
|
|
* ErrorHandler class file. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
|
|
|
|
* @link http://www.yiiframework.com/ |
|
|
|
* @link http://www.yiiframework.com/ |
|
|
|
* @copyright Copyright © 2008-2011 Yii Software LLC |
|
|
|
* @copyright Copyright © 2008-2012 Yii Software LLC |
|
|
|
* @license http://www.yiiframework.com/license/ |
|
|
|
* @license http://www.yiiframework.com/license/ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
Yii::import('CHtml',true); |
|
|
|
namespace yii\base; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* CErrorHandler handles uncaught PHP errors and exceptions. |
|
|
|
* ErrorHandler handles uncaught PHP errors and exceptions. |
|
|
|
* |
|
|
|
* |
|
|
|
* It displays these errors using appropriate views based on the |
|
|
|
* It displays these errors using appropriate views based on the |
|
|
|
* nature of the error and the mode the application runs at. |
|
|
|
* nature of the error and the mode the application runs at. |
|
|
|
* It also chooses the most preferred language for displaying the error. |
|
|
|
* It also chooses the most preferred language for displaying the error. |
|
|
|
* |
|
|
|
* |
|
|
|
* CErrorHandler uses two sets of views: |
|
|
|
* ErrorHandler uses two sets of views: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>development views, named as <code>exception.php</code>; |
|
|
|
* <li>development views, named as <code>exception.php</code>; |
|
|
|
* <li>production views, named as <code>error<StatusCode>.php</code>; |
|
|
|
* <li>production views, named as <code>error<StatusCode>.php</code>; |
|
|
@ -33,7 +32,7 @@ Yii::import('CHtml',true); |
|
|
|
* For security reasons, they only display the error message without any |
|
|
|
* For security reasons, they only display the error message without any |
|
|
|
* sensitive information. |
|
|
|
* sensitive information. |
|
|
|
* |
|
|
|
* |
|
|
|
* CErrorHandler looks for the view templates from the following locations in order: |
|
|
|
* ErrorHandler looks for the view templates from the following locations in order: |
|
|
|
* <ol> |
|
|
|
* <ol> |
|
|
|
* <li><code>themes/ThemeName/views/system</code>: when a theme is active.</li> |
|
|
|
* <li><code>themes/ThemeName/views/system</code>: when a theme is active.</li> |
|
|
|
* <li><code>protected/views/system</code></li> |
|
|
|
* <li><code>protected/views/system</code></li> |
|
|
@ -44,17 +43,15 @@ Yii::import('CHtml',true); |
|
|
|
* The property {@link maxSourceLines} can be changed to specify the number |
|
|
|
* The property {@link maxSourceLines} can be changed to specify the number |
|
|
|
* of source code lines to be displayed in development views. |
|
|
|
* of source code lines to be displayed in development views. |
|
|
|
* |
|
|
|
* |
|
|
|
* CErrorHandler is a core application component that can be accessed via |
|
|
|
* ErrorHandler is a core application component that can be accessed via |
|
|
|
* {@link CApplication::getErrorHandler()}. |
|
|
|
* {@link CApplication::getErrorHandler()}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @property array $error The error details. Null if there is no error. |
|
|
|
* @property array $error The error details. Null if there is no error. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @version $Id$ |
|
|
|
* @since 2.0 |
|
|
|
* @package system.base |
|
|
|
|
|
|
|
* @since 1.0 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CErrorHandler extends CApplicationComponent |
|
|
|
class ErrorHandler extends ApplicationComponent |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var integer maximum number of source code lines to be displayed. Defaults to 25. |
|
|
|
* @var integer maximum number of source code lines to be displayed. Defaults to 25. |
|
|
@ -63,7 +60,6 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var integer maximum number of trace source code lines to be displayed. Defaults to 10. |
|
|
|
* @var integer maximum number of trace source code lines to be displayed. Defaults to 10. |
|
|
|
* @since 1.1.6 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $maxTraceSourceLines = 10; |
|
|
|
public $maxTraceSourceLines = 10; |
|
|
|
|
|
|
|
|
|
|
@ -74,99 +70,106 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var boolean whether to discard any existing page output before error display. Defaults to true. |
|
|
|
* @var boolean whether to discard any existing page output before error display. Defaults to true. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $discardOutput=true; |
|
|
|
public $discardExistingOutput = true; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the route (eg 'site/error') to the controller action that will be used to display external errors. |
|
|
|
* @var string the route (eg 'site/error') to the controller action that will be used to display external errors. |
|
|
|
* Inside the action, it can retrieve the error information by Yii::app()->errorHandler->error. |
|
|
|
* Inside the action, it can retrieve the error information by Yii::app()->errorHandler->error. |
|
|
|
* This property defaults to null, meaning CErrorHandler will handle the error display. |
|
|
|
* This property defaults to null, meaning ErrorHandler will handle the error display. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $errorAction; |
|
|
|
public $errorAction; |
|
|
|
|
|
|
|
|
|
|
|
private $_error; |
|
|
|
private $_error; |
|
|
|
|
|
|
|
public $exception; |
|
|
|
|
|
|
|
public $compactOutput; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
public function init() |
|
|
|
* Handles the exception/error event. |
|
|
|
|
|
|
|
* This method is invoked by the application whenever it captures |
|
|
|
|
|
|
|
* an exception or PHP error. |
|
|
|
|
|
|
|
* @param CEvent $event the event containing the exception/error information |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function handle($event) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// set event as handled to prevent it from being handled by other event handlers |
|
|
|
set_exception_handler(array($this, 'handleException')); |
|
|
|
$event->handled=true; |
|
|
|
set_error_handler(array($this, 'handleError'), error_reporting()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($this->discardOutput) |
|
|
|
protected function logException($exception) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// the following manual level counting is to deal with zlib.output_compression set to On |
|
|
|
$category = get_class($exception); |
|
|
|
for($level=ob_get_level();$level>0;--$level) |
|
|
|
if ($exception instanceof HttpException) { |
|
|
|
|
|
|
|
$category .= '\\' . $exception->statusCode; |
|
|
|
|
|
|
|
} elseif ($exception instanceof \ErrorException) { |
|
|
|
|
|
|
|
$category .= '\\' . $exception->getSeverity(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
\Yii::error((string)$exception, $category); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function clearOutput() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// the following manual level counting is to deal with zlib.output_compression set to On |
|
|
|
|
|
|
|
for ($level = ob_get_level(); $level > 0; --$level) { |
|
|
|
@ob_end_clean(); |
|
|
|
@ob_end_clean(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($event instanceof CExceptionEvent) |
|
|
|
protected function simple() |
|
|
|
$this->handleException($event->exception); |
|
|
|
{ |
|
|
|
else // CErrorEvent |
|
|
|
if (YII_DEBUG) { |
|
|
|
$this->handleError($event); |
|
|
|
echo '<h1>' . get_class($exception) . "</h1>\n"; |
|
|
|
|
|
|
|
echo '<p>' . $exception->getMessage() . ' (' . $exception->getFile() . ':' . $exception->getLine() . ')</p>'; |
|
|
|
|
|
|
|
echo '<pre>' . $exception->getTraceAsString() . '</pre>'; |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
echo '<h1>' . get_class($exception) . "</h1>\n"; |
|
|
|
|
|
|
|
echo '<p>' . $exception->getMessage() . '</p>'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the details about the error that is currently being handled. |
|
|
|
* @param \Exception $exception |
|
|
|
* The error is returned in terms of an array, with the following information: |
|
|
|
|
|
|
|
* <ul> |
|
|
|
|
|
|
|
* <li>code - the HTTP status code (e.g. 403, 500)</li> |
|
|
|
|
|
|
|
* <li>type - the error type (e.g. 'CHttpException', 'PHP Error')</li> |
|
|
|
|
|
|
|
* <li>message - the error message</li> |
|
|
|
|
|
|
|
* <li>file - the name of the PHP script file where the error occurs</li> |
|
|
|
|
|
|
|
* <li>line - the line number of the code where the error occurs</li> |
|
|
|
|
|
|
|
* <li>trace - the call stack of the error</li> |
|
|
|
|
|
|
|
* <li>source - the context source code where the error occurs</li> |
|
|
|
|
|
|
|
* </ul> |
|
|
|
|
|
|
|
* @return array the error details. Null if there is no error. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getError() |
|
|
|
public function handleException($exception) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_error; |
|
|
|
$this->exception = $exception; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// disable error capturing to avoid recursive errors |
|
|
|
|
|
|
|
restore_error_handler(); |
|
|
|
|
|
|
|
restore_exception_handler(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->logException($exception); |
|
|
|
|
|
|
|
if ($this->discardExistingOutput) { |
|
|
|
|
|
|
|
$this->clearOutput(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
if ($this->compactOutput === null) { |
|
|
|
* Handles the exception. |
|
|
|
// not in Web application, or not in AJAX request |
|
|
|
* @param Exception $exception the exception captured |
|
|
|
$this->compactOutput = !(\Yii::$application instanceof \yii\web\Application) || isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; |
|
|
|
*/ |
|
|
|
} |
|
|
|
protected function handleException($exception) |
|
|
|
|
|
|
|
{ |
|
|
|
if ($this->compactOutput) { |
|
|
|
$app=Yii::app(); |
|
|
|
$this->simple(); |
|
|
|
if($app instanceof CWebApplication) |
|
|
|
return; |
|
|
|
{ |
|
|
|
} |
|
|
|
if(($trace=$this->getExactTrace($exception))===null) |
|
|
|
|
|
|
|
{ |
|
|
|
if (($trace = $this->getExactTrace($exception)) === null) { |
|
|
|
$fileName = $exception->getFile(); |
|
|
|
$fileName = $exception->getFile(); |
|
|
|
$errorLine = $exception->getLine(); |
|
|
|
$errorLine = $exception->getLine(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$fileName = $trace['file']; |
|
|
|
$fileName = $trace['file']; |
|
|
|
$errorLine = $trace['line']; |
|
|
|
$errorLine = $trace['line']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$trace = $exception->getTrace(); |
|
|
|
$trace = $exception->getTrace(); |
|
|
|
|
|
|
|
foreach ($trace as $i => $t) { |
|
|
|
foreach($trace as $i=>$t) |
|
|
|
if (!isset($t['file'])) { |
|
|
|
{ |
|
|
|
|
|
|
|
if(!isset($t['file'])) |
|
|
|
|
|
|
|
$trace[$i]['file'] = 'unknown'; |
|
|
|
$trace[$i]['file'] = 'unknown'; |
|
|
|
|
|
|
|
} |
|
|
|
if(!isset($t['line'])) |
|
|
|
if (!isset($t['line'])) { |
|
|
|
$trace[$i]['line'] = 0; |
|
|
|
$trace[$i]['line'] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
if(!isset($t['function'])) |
|
|
|
if (!isset($t['function'])) { |
|
|
|
$trace[$i]['function'] = 'unknown'; |
|
|
|
$trace[$i]['function'] = 'unknown'; |
|
|
|
|
|
|
|
} |
|
|
|
unset($trace[$i]['object']); |
|
|
|
unset($trace[$i]['object']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->_error = $data = array( |
|
|
|
$this->_error = $data = array( |
|
|
|
'code'=>($exception instanceof CHttpException)?$exception->statusCode:500, |
|
|
|
'code' => $exception instanceof HttpException ? $exception->statusCode : 500, |
|
|
|
'type' => get_class($exception), |
|
|
|
'type' => get_class($exception), |
|
|
|
'errorCode' => $exception->getCode(), |
|
|
|
'errorCode' => $exception->getCode(), |
|
|
|
'message' => $exception->getMessage(), |
|
|
|
'message' => $exception->getMessage(), |
|
|
@ -176,21 +179,34 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
'traces' => $trace, |
|
|
|
'traces' => $trace, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if(!headers_sent()) |
|
|
|
if (!headers_sent()) { |
|
|
|
header("HTTP/1.0 {$data['code']} " . get_class($exception)); |
|
|
|
header("HTTP/1.0 {$data['code']} " . get_class($exception)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($exception instanceof CHttpException || !YII_DEBUG) |
|
|
|
if ($exception instanceof HttpException || !YII_DEBUG) { |
|
|
|
$this->render('error', $data); |
|
|
|
$this->render('error', $data); |
|
|
|
else |
|
|
|
} else { |
|
|
|
{ |
|
|
|
|
|
|
|
if($this->isAjaxRequest()) |
|
|
|
|
|
|
|
$app->displayException($exception); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$this->render('exception', $data); |
|
|
|
$this->render('exception', $data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
$app->displayException($exception); |
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the details about the error that is currently being handled. |
|
|
|
|
|
|
|
* The error is returned in terms of an array, with the following information: |
|
|
|
|
|
|
|
* <ul> |
|
|
|
|
|
|
|
* <li>code - the HTTP status code (e.g. 403, 500)</li> |
|
|
|
|
|
|
|
* <li>type - the error type (e.g. 'CHttpException', 'PHP Error')</li> |
|
|
|
|
|
|
|
* <li>message - the error message</li> |
|
|
|
|
|
|
|
* <li>file - the name of the PHP script file where the error occurs</li> |
|
|
|
|
|
|
|
* <li>line - the line number of the code where the error occurs</li> |
|
|
|
|
|
|
|
* <li>trace - the call stack of the error</li> |
|
|
|
|
|
|
|
* <li>source - the context source code where the error occurs</li> |
|
|
|
|
|
|
|
* </ul> |
|
|
|
|
|
|
|
* @return array the error details. Null if there is no error. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function getError() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_error; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -224,8 +240,7 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$app = Yii::app(); |
|
|
|
$app = Yii::app(); |
|
|
|
if($app instanceof CWebApplication) |
|
|
|
if ($app instanceof CWebApplication) { |
|
|
|
{ |
|
|
|
|
|
|
|
switch ($event->code) |
|
|
|
switch ($event->code) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case E_WARNING: |
|
|
|
case E_WARNING: |
|
|
@ -272,29 +287,19 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* whether the current request is an AJAX (XMLHttpRequest) request. |
|
|
|
|
|
|
|
* @return boolean whether the current request is an AJAX request. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected function isAjaxRequest() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the exact trace where the problem occurs. |
|
|
|
* Returns the exact trace where the problem occurs. |
|
|
|
* @param Exception $exception the uncaught exception |
|
|
|
* @param \Exception $exception the uncaught exception |
|
|
|
* @return array the exact trace where the problem occurs |
|
|
|
* @return array the exact trace where the problem occurs |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function getExactTrace($exception) |
|
|
|
protected function getExactTrace($exception) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$traces = $exception->getTrace(); |
|
|
|
$traces = $exception->getTrace(); |
|
|
|
|
|
|
|
foreach ($traces as $trace) { |
|
|
|
foreach($traces as $trace) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// property access exception |
|
|
|
// property access exception |
|
|
|
if(isset($trace['function']) && ($trace['function']==='__get' || $trace['function']==='__set')) |
|
|
|
if (isset($trace['function']) && ($trace['function'] === '__get' || $trace['function'] === '__set')) { |
|
|
|
return $trace; |
|
|
|
return $trace; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -334,8 +339,7 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
|
|
|
|
|
|
|
|
foreach ($viewPaths as $i => $viewPath) |
|
|
|
foreach ($viewPaths as $i => $viewPath) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if($viewPath!==null) |
|
|
|
if ($viewPath !== null) { |
|
|
|
{ |
|
|
|
|
|
|
|
$viewFile = $this->getViewFileInternal($viewPath, $view, $code, $i === 2 ? 'en_us' : null); |
|
|
|
$viewFile = $this->getViewFileInternal($viewPath, $view, $code, $i === 2 ? 'en_us' : null); |
|
|
|
if (is_file($viewFile)) |
|
|
|
if (is_file($viewFile)) |
|
|
|
return $viewFile; |
|
|
|
return $viewFile; |
|
|
@ -354,8 +358,7 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
protected function getViewFileInternal($viewPath, $view, $code, $srcLanguage = null) |
|
|
|
protected function getViewFileInternal($viewPath, $view, $code, $srcLanguage = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$app = Yii::app(); |
|
|
|
$app = Yii::app(); |
|
|
|
if($view==='error') |
|
|
|
if ($view === 'error') { |
|
|
|
{ |
|
|
|
|
|
|
|
$viewFile = $app->findLocalizedFile($viewPath . DIRECTORY_SEPARATOR . "error{$code}.php", $srcLanguage); |
|
|
|
$viewFile = $app->findLocalizedFile($viewPath . DIRECTORY_SEPARATOR . "error{$code}.php", $srcLanguage); |
|
|
|
if (!is_file($viewFile)) |
|
|
|
if (!is_file($viewFile)) |
|
|
|
$viewFile = $app->findLocalizedFile($viewPath . DIRECTORY_SEPARATOR . 'error.php', $srcLanguage); |
|
|
|
$viewFile = $app->findLocalizedFile($viewPath . DIRECTORY_SEPARATOR . 'error.php', $srcLanguage); |
|
|
@ -372,14 +375,14 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function getVersionInfo() |
|
|
|
protected function getVersionInfo() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(YII_DEBUG) |
|
|
|
if (YII_DEBUG) { |
|
|
|
{ |
|
|
|
$version = '<a href="http://www.yiiframework.com/">Yii Framework</a>/' . \Yii::getVersion(); |
|
|
|
$version='<a href="http://www.yiiframework.com/">Yii Framework</a>/'.Yii::getVersion(); |
|
|
|
if (isset($_SERVER['SERVER_SOFTWARE'])) { |
|
|
|
if(isset($_SERVER['SERVER_SOFTWARE'])) |
|
|
|
|
|
|
|
$version = $_SERVER['SERVER_SOFTWARE'] . ' ' . $version; |
|
|
|
$version = $_SERVER['SERVER_SOFTWARE'] . ' ' . $version; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
} else { |
|
|
|
$version = ''; |
|
|
|
$version = ''; |
|
|
|
|
|
|
|
} |
|
|
|
return $version; |
|
|
|
return $version; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -398,8 +401,7 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
foreach ($args as $key => $value) |
|
|
|
foreach ($args as $key => $value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$count++; |
|
|
|
$count++; |
|
|
|
if($count>=5) |
|
|
|
if ($count >= 5) { |
|
|
|
{ |
|
|
|
|
|
|
|
if ($count > 5) |
|
|
|
if ($count > 5) |
|
|
|
unset($args[$key]); |
|
|
|
unset($args[$key]); |
|
|
|
else |
|
|
|
else |
|
|
@ -411,8 +413,7 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
$args[$key] = get_class($value); |
|
|
|
$args[$key] = get_class($value); |
|
|
|
else if (is_bool($value)) |
|
|
|
else if (is_bool($value)) |
|
|
|
$args[$key] = $value ? 'true' : 'false'; |
|
|
|
$args[$key] = $value ? 'true' : 'false'; |
|
|
|
else if(is_string($value)) |
|
|
|
else if (is_string($value)) { |
|
|
|
{ |
|
|
|
|
|
|
|
if (strlen($value) > 64) |
|
|
|
if (strlen($value) > 64) |
|
|
|
$args[$key] = '"' . substr($value, 0, 64) . '..."'; |
|
|
|
$args[$key] = '"' . substr($value, 0, 64) . '..."'; |
|
|
|
else |
|
|
|
else |
|
|
@ -425,12 +426,10 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
else if (is_resource($value)) |
|
|
|
else if (is_resource($value)) |
|
|
|
$args[$key] = 'resource'; |
|
|
|
$args[$key] = 'resource'; |
|
|
|
|
|
|
|
|
|
|
|
if(is_string($key)) |
|
|
|
if (is_string($key)) { |
|
|
|
{ |
|
|
|
|
|
|
|
$args[$key] = '"' . $key . '" => ' . $args[$key]; |
|
|
|
$args[$key] = '"' . $key . '" => ' . $args[$key]; |
|
|
|
} |
|
|
|
} |
|
|
|
else if($isAssoc) |
|
|
|
else if ($isAssoc) { |
|
|
|
{ |
|
|
|
|
|
|
|
$args[$key] = $key . ' => ' . $args[$key]; |
|
|
|
$args[$key] = $key . ' => ' . $args[$key]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -446,8 +445,7 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function isCoreCode($trace) |
|
|
|
protected function isCoreCode($trace) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(isset($trace['file'])) |
|
|
|
if (isset($trace['file'])) { |
|
|
|
{ |
|
|
|
|
|
|
|
$systemPath = realpath(dirname(__FILE__) . '/..'); |
|
|
|
$systemPath = realpath(dirname(__FILE__) . '/..'); |
|
|
|
return $trace['file'] === 'unknown' || strpos(realpath($trace['file']), $systemPath . DIRECTORY_SEPARATOR) === 0; |
|
|
|
return $trace['file'] === 'unknown' || strpos(realpath($trace['file']), $systemPath . DIRECTORY_SEPARATOR) === 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -484,4 +482,26 @@ class CErrorHandler extends CApplicationComponent |
|
|
|
} |
|
|
|
} |
|
|
|
return '<div class="code"><pre>' . $output . '</pre></div>'; |
|
|
|
return '<div class="code"><pre>' . $output . '</pre></div>'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Handles PHP execution errors such as warnings, notices. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* This method is implemented as a PHP error handler. It requires |
|
|
|
|
|
|
|
* that constant YII_ENABLE_ERROR_HANDLER be defined true. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* This method will first raise an `error` event. |
|
|
|
|
|
|
|
* If the error is not handled by any event handler, it will call |
|
|
|
|
|
|
|
* {@link getErrorHandler errorHandler} to process the error. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* The application will be terminated by this method. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param integer $code the level of the error raised |
|
|
|
|
|
|
|
* @param string $message the error message |
|
|
|
|
|
|
|
* @param string $file the filename that the error was raised in |
|
|
|
|
|
|
|
* @param integer $line the line number the error was raised at |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function handleError($code, $message, $file, $line) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
throw new \ErrorException($message, 0, $code, $file, $line); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|