|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-24 20:04 UTC] gabe at mudbugmedia dot com
Description:
------------
Periodically PHP stops respecting calls to error_reporting() to alter
the current error level away from the system default specified in
php.ini. All calls to error_reporting() for the current connection
will not update the actual level. This behavior will occur with only
*some* of the connections, but not all of them. Reloading the page
(after waiting for the keep alive to time out) will sometimes result
in the expected behavior, and others will result in the erroneous
behavior. Restarting Apache (running 2.2.6 with mod_php) seems to
briefly fix the problem, but it eventually returns.
This behavior also occurs when trying to set the error reporting level
via .htaccess such as:
php_value "E_ALL ^ E_NOTICE"
when this occurs, a phpinfo() call shows that the error reporting
level has defaulted back to the system-wide default (specified in
php.ini) and ignores the php_value statement all together. Again,
this is behavior that only happens *sometimes* and alters between page
reloads.
As a side effect, this causes all supporting libraries that rely on
error suppression, like Smarty, to throw errors.
Reproduce code:
---------------
<?php
var_dump(error_reporting());
var_dump(error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE));
trigger_error('This should not be seen', E_USER_NOTICE);
echo $a; // should cause a notice
var_dump(error_reporting());
?>
Expected result:
----------------
int(6143)
int(6143)
int(5111)
Actual result:
--------------
int(6143)
int(6143)
<br />
<b>Notice</b>: This should not be seen in
<b>/home/gabebug/public_html/error_reporting_tests.php</b> on line
<b>5</b><br
/>
<br />
<b>Notice</b>: Undefined variable: a in
<b>/home/gabebug/public_html/error_reporting_tests.php</b> on line
<b>6</b><br
/>
int(6143)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
I extended my reproduction code to check ini_set(), which suffers the same behavior. Code: <?php var_dump(error_reporting()); var_dump(error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE)); trigger_error('This should not be seen', E_USER_NOTICE); echo $a; // should cause a notice var_dump(error_reporting()); var_dump(ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_USER_NOTICE ^ E_USER_WARNING)); var_dump(error_reporting()); trigger_error('This should not be seen', E_USER_NOTICE); echo $a; // should cause a notice var_dump(error_reporting()); ?> Output: int(6143) int(6143) Notice: This should not be seen in /home/gabebug/public_html/error_reporting_tests.php on line 5 Notice: Undefined variable: a in /home/gabebug/public_html/error_reporting_tests.php on line 6 int(6143) bool(false) int(6143) Notice: This should not be seen in /home/gabebug/public_html/error_reporting_tests.php on line 11 Notice: Undefined variable: a in /home/gabebug/public_html/error_reporting_tests.php on line 12 int(6143)