Question about error_reporting()
Hi guys, I am looking at the implementation of error_reporting: http://api.drupal.org/api/function/error_handler/5 and I don't understand this line: if ($errno & (E_ALL ^ E_NOTICE)) { does it means that all errors but E_NOTICE are gonna be reported ? (what I really dont get is the meaning of the ^ php operator....).... I am trying to understand this code because my watchdog table is getting full of PHP warning messages, and I was not able to found a configuration option to filter this kind of messages. Would it be possible to change the behaviour to report messages above or below a specific level like it is done in php.ini ? Thanks in advance.
The ^ is the bitwise NOT operator in PHP. PHP defines a bunch of bitmasks to flag different error levels. E_ALL is the bit mask for "everything except STRICT-level", so that line means "everything except STRICT level but not NOTICE level". If your watchdog table is filling up with PHP warning messages, then you have a serious bug in your code somewhere. Do not hide the error. Fix the bug. :-) Look at the error message itself to see what the problem is, track it down, and squish it. --Larry Garfield On Fri, 8 Aug 2008 15:10:50 +0200, "Juan Rodriguez" <juan.fco.rodriguez@gmail.com> wrote:
Hi guys,
I am looking at the implementation of error_reporting: http://api.drupal.org/api/function/error_handler/5
and I don't understand this line:
if ($errno & (E_ALL ^ E_NOTICE)) {
does it means that all errors but E_NOTICE are gonna be reported ? (what I really dont get is the meaning of the ^ php operator....)....
I am trying to understand this code because my watchdog table is getting full of PHP warning messages, and I was not able to found a configuration option to filter this kind of messages.
Would it be possible to change the behaviour to report messages above or below a specific level like it is done in php.ini ?
Thanks in advance.
Quoting Larry Garfield <larry@garfieldtech.com>:
If your watchdog table is filling up with PHP warning messages, then you have a serious bug in your code somewhere. Do not hide the error. Fix the bug. :-) Look at the error message itself to see what the problem is, track it down, and squish it.
There's a few from DRUPAL-5 that happen with every page load such as "page not found 2008-08-08 14:56 favicon.ico". There details of the "warning" do not tell me a referrer. To squash it I tend to "touch favicon.ico" in the DocumentRoot directory. Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
Huh? That's watchdog() called directly on 404 pages, not an error handling problem. It's an IE problem, actually - IE just looks in the root directory for favicon.ico ignoring the reference to the favicon in the html. -Charlie Earnie Boyd wrote:
There's a few from DRUPAL-5 that happen with every page load such as "page not found 2008-08-08 14:56 favicon.ico". There details of the "warning" do not tell me a referrer. To squash it I tend to "touch favicon.ico" in the DocumentRoot directory.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
Quoting Charlie Gordon <cwgordon7@cwgordon.com>:
Huh? That's watchdog() called directly on 404 pages, not an error handling problem. It's an IE problem, actually - IE just looks in the root directory for favicon.ico ignoring the reference to the favicon in the html.
The OP is looking for ways to cut down on the watchdog entry fluff. While PNF errors in the watchdog themselves are not fluff the favicon.ico one certainly is. Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
One more thing, I think that in this line: watchdog('php', t('%message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line)), WATCHDOG_ERROR); %error is not being interpolated, wouldn't it be better something like t('%error: %message in %file....blablabla....) ? On Fri, Aug 8, 2008 at 7:58 PM, Earnie Boyd <earnie@users.sourceforge.net> wrote:
Quoting Charlie Gordon <cwgordon7@cwgordon.com>:
Huh? That's watchdog() called directly on 404 pages, not an error handling problem. It's an IE problem, actually - IE just looks in the root directory for favicon.ico ignoring the reference to the favicon in the html.
The OP is looking for ways to cut down on the watchdog entry fluff. While PNF errors in the watchdog themselves are not fluff the favicon.ico one certainly is.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
For the favicon issue see http://drupal.org/node/174940 which is looking to be ported to D5 but is already taken care of in versions higher than that. You can, also, see http://drupal.org/project/favicon. Quoting Earnie Boyd <earnie@users.sourceforge.net>:
Quoting Larry Garfield <larry@garfieldtech.com>:
If your watchdog table is filling up with PHP warning messages, then you have a serious bug in your code somewhere. Do not hide the error. Fix the bug. :-) Look at the error message itself to see what the problem is, track it down, and squish it.
There's a few from DRUPAL-5 that happen with every page load such as "page not found 2008-08-08 14:56 favicon.ico". There details of the "warning" do not tell me a referrer. To squash it I tend to "touch favicon.ico" in the DocumentRoot directory.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
participants (5)
-
Charlie Gordon -
Earnie Boyd -
Juan Rodriguez -
Larry Garfield -
matt@mattfarina.com