When handling a PHP error, Yii will always end the app, regardless of the type of error message. This means that even PHP notices will kill your app (unless you change your error_reporting level). Personally, I would like to be able to process all PHP errors, but exit only on most severe ones. So if it is a notice, I would just log it and move on, if it is a warning, I might email it to developers and move on, etc.
One solution might be to end the app ONLY if error event was not handled, so we would add the following before line 816 of CApplication:
if($event->handled)
return false; //PHP error handling takes over when false is returned
Also, you should perhaps perform logging only when event was not handled (line 800):
if(!$event->handled)
{
//log here and not on line 793
Yii::log($log,CLogger::LEVEL_ERROR,'php');
// try an error handler
...
However, there is still the question of handling the most severe PHP errors. PHP manual says:
It seems that the only way to handle these errors is by registering a shutdown function and then examining the return value of error_get_last(). Could CApplication register a shutdown function which would perform a similar type of error handling as in handleError() method? That way, if I define my own error handler for PHP errors, that handler would be called even for the most severe types of PHP errors, such as E_ERROR or E_PARSE. This is how it might look like:
public function handleSevereError()
{
$error = error_get_last();
if ($error)
{
Yii::import('CErrorEvent',true);
$event=new CErrorEvent($this,$error['type'],$error['message'],$error['file'],$error['line']);
$this->onError($event);
}
}
And in initSystemHandlers(), you would simply add:
register_shutdown_function(array($this, 'handleSevereError'));
Thoughts and ideas are welcome.