|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-02-17 00:44 UTC] tyra3l at gmail dot com
Description: ------------ my co-worker had a problem with the Zend Framework Soap Server class: he was using trigger_error for handling the application level errors, and the ZF Soap Server class set his own error_handler, so my co-worker's error handler was swapped out, and his E_USER_WARNING/E_USER_ERROR errors was ignored (if you have an userspace error handler then every error type, which isn't observed will be discarded) I mentioned this on twitter (I wasn't really nice) http://twitter.com/#!/Tyr43l/status/22704699030 and Matthew Weier O'Phinney responded that they had to do this, because there was some quirks about the SoapServer or DomDocument class. so if they don't set their error_handler, they can't handle the error, if they do, they will overwrite any existing error_handler. if there would be a way, to get the current(previous) error handler, then they could have save the current/previous error handler (with the error type parameter!) and from their error handler, they could have call the applevel error handler callback. of course, some stackable mechanism, like the spl_autoload would be a more better approach but that would break BC, at least I couldn't figure out a way to do it without problems. I will ask Matthew to comment on this issue (what was the exact problem that forced them to set the error handler at the first place) PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 03:00:01 2025 UTC |
I'm not sure the focus was of the exception handler and the reason I bring this up is you have mentioned about restoring the exception handler, however I think this bug applies to exceptions as well. I think for security alone, you should be able to call get_error_handler as if a rogue script has overridden the error handler you have no way of knowing without changing the error handler. Because there is no get_error_handler() you have to type: function tempErrorHandler () {} $previousErrorHandler = set_error_handler('tempErrorHandler'); restore_error_handler(); Even worse, people are probably writing a function called get_error_handler() to do this because you haven't provided this functionality. This means when you come to implement something like this you will have to provide enough time for people to remove their own implementation of this function. Another issue is how to restore the original PHP error handler, take for instance the following scenario: function tempErrorHandler () {} function basicErrorHandler () {} set_error_handler('tempErrorHandler'); set_error_handler('basicErrorHandler'); Calling restore_error_handler() restores the tempErrorHandler, that's great, we now have an error handler that is doing nothing. Please seriously reconsider your stance on the functionality provided for both the error and exception handling.For anyone else who finds the implementation of the error handling functions a bug, the following might help: function void_error_handler () {} function get_error_handler () { $error_handler = set_error_handler('void_error_handler'); restore_error_handler(); return $error_handler; } function restore_php_error_handler () { while (set_error_handler('void_error_handler') !== NULL) { restore_error_handler(); restore_error_handler(); } } This is what we have to resort to, stop not admitting this is a bug when it is!