-/**
-* Error handler used to track errors that occur during server-side execution of PHP code.
-* This allows to report back to the client whether an internal error has occurred or not
-* using an xmlrpc response object, instead of letting the client deal with the html junk
-* that a PHP execution error on the server generally entails.
-*
-* NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors.
-*
-*/
-function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null)
-{
- // obey the @ protocol
- if (error_reporting() == 0)
- return;
-
- //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING)
- if($errcode != E_STRICT)
- {
- $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n";
- }
- // Try to avoid as much as possible disruption to the previous error handling
- // mechanism in place
- if($GLOBALS['_xmlrpcs_prev_ehandler'] == '')
- {
- // The previous error handler was the default: all we should do is log error
- // to the default error log (if level high enough)
- if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode))
- {
- error_log($errstring);
- }
- }
- else
- {
- // Pass control on to previous error handler, trying to avoid loops...
- if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler')
- {
- // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers
- if(is_array($GLOBALS['_xmlrpcs_prev_ehandler']))
- {
- // the following works both with static class methods and plain object methods as error handler
- call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context));
- }
- else
- {
- $GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context);
- }
- }
- }
-}
-
-