Capplication Handleerror() Ends App

I don’t see why the handleError() method of CApplication has to always terminate the application. For example, when uploading a file and the move_uploaded_file function fails, it is not good to just blow up with a “WARNING, failed to move etc.”. I have registered an error event and I want this handled gracefully in my controller, showing form validation results normally.

So I request that handleError() provide a mechanism of not always terminating the app. Probably an attribute in CApplication of some sort of a callback filtering the error. For example, my ‘terminateOrNot’ callback could whitelist move_uploaded_file based on stack trace.

Just for reference, I have hacked yii (horribly) to enable event handling for this function. This is my main index.php.


<?php


// change the following paths if necessary

//$yii=dirname(__FILE__).'/../CGV/yii-1.1.13.e9e4a0/framework/yii.php';

$yii=dirname(__FILE__).'/../CGV/yii-1.1.13.e9e4a0/framework/YiiBase.php';

$config=dirname(__FILE__).'/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);


class MyYiiBase extends YiiBase {

	public static function createMyWebApplication($config=null)

	{

		return self::createApplication('MyWebApplication',$config);

	}

}


class MyWebApplication extends CWebApplication {

	public function end($status=0,$exit=true)

	{

		$trace=debug_backtrace(false);

		$caller=array_shift($trace);

		$caller=array_shift($trace);

		$caller2=array_shift($trace);


		if ( $caller['function'] == 'handleError' &&

			$caller['class'] == 'CApplication' &&

			$caller2['function'] == 'move_uploaded_file' ) {

			$exit = false; //block ending the application if called from handleError about move uploaded file

		}

		return CWebApplication::end($status,$exit);

	}

}


class Yii extends MyYiiBase

{

}


Yii::createMyWebApplication($config)->run();