set_error_handler and error supression

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

set_error_handler and error supression

Post by shiznatix »

Ok so here's the deal. I have a custom error handler that I use to send myself an email every time there is an error of any sort (E_ALL). Now this was great because it would help me find small bugs in my code that might have seeped through or even let me know that mysql went down for whatever reason...blah blah blah.

Now I switched to the Zend Framework and it uses some error suppressing when trying to load the Controller class. This is because sometimes the controller file won't be there because maybe its a "file not found" page or something. Anyway, I have a plugin that redirects all of these unknown controller requests to a custom file not found page. Great. Awesome. The problem is that there is a @fopen() call which basically returns false because the file does not exist. When the file does not exist, I get an email saying "file does not exist" and im sitting here going "i know!!!!".

So is there a way to get errors that are suppressed like that to not go into my custom error handler? These are the only emails I do not care about and I am getting a million of them.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: set_error_handler and error supression

Post by superdezign »

Have you tried getting rid of that call since it will always return false?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: set_error_handler and error supression

Post by Christopher »

Why not just edit the Zend controller file and remove the @. It might be a pain, but you only need to do it when you install or upgraded.
(#10850)
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: set_error_handler and error supression

Post by shiznatix »

ok i found the solution actually but don't quite know how to use it yet. I will look into it more tomorrow but if anyone wanted to know it is here:
It is important to remember that the standard PHP error handler is completely bypassed. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.
Post Reply