Show the parameters of called functions on CErrorHandler::...

Sometimes, I cann’t get the exact error reason from trace info generated by Yii, because I donn’t know what arguments were passed to the function.

I did it by myself, just modify the file: framework/base/CErrorHandler.php




*** CErrorHandler.php.orig	Sun Aug  9 00:28:26 2009

--- CErrorHandler.php	Sun Aug 23 18:56:35 2009

***************

*** 175,184 ****

  				$t['line']=0;

  			if(!isset($t['function']))

  				$t['function']='unknown';

  			$traceString.="#$i {$t['file']}({$t['line']}): ";

  			if(isset($t['object']) && is_object($t['object']))

  				$traceString.=get_class($t['object']).'->';

! 			$traceString.="{$t['function']}()\n";

  		}

  

  		$app=Yii::app();

--- 175,201 ----

  				$t['line']=0;

  			if(!isset($t['function']))

  				$t['function']='unknown';

+ 			// hightman.090819: display all parameters of called functions.

+ 			$argString='';

+ 			if(isset($t['args']) && count($t['args']) > 0)

+ 			{

+ 				foreach($t['args'] as $a)

+ 				{

+ 					if(is_null($a)) $argString.=',NULL';

+ 					else if(is_bool($a)) $argString.=','.($a ? 'true' : 'false').'';

+ 					else if(is_int($a) || is_float($a)) $argString.=','.$a;

+ 					else if(is_string($a)) $argString.=',\''.((strlen($a) > 60) ? substr($a,0,16).'...' : $a).'\'';

+ 					else if(is_array($a)) $argString.=',array('.count($a).')';

+ 					else if(is_object($a)) $argString.=',object('.get_class($a).')';

+ 					else if(is_resource($a)) $argString.=',resource('.get_resource_type($a).')';

+ 					else $argString.=',??';

+ 				}

+ 				$argString = substr($argString,1);

+ 			}

  			$traceString.="#$i {$t['file']}({$t['line']}): ";

  			if(isset($t['object']) && is_object($t['object']))

  				$traceString.=get_class($t['object']).'->';

! 			$traceString.="{$t['function']}({$argString})\n";			

  		}

  

  		$app=Yii::app();




This is great! I think this deserves to be created as a ticket, that way it might get more attention.

Welcome to the forums!

Thanks, but I cann’t forward or move the thread to “Tips” board.

Can any administrator of the forums help me?

I actually think this would be good to be the default implementation, so let it be between feature requests, as stack traces are only shown in debug stages.

Excellent idea. Saves from wasting time on CVarDump-ing.