Bug #81454 [NEW]: error_reporting() and ini_get('error_reporting') can get out of sync using @
| From: | daimona dot wiki at gmail dot com | Date: | Fri, 17 Sep 2021 19:37:54 +0000 |
| Subject: | Bug #81454 [NEW]: error_reporting() and ini_get('error_reporting') can get out of sync using @ | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236669@lists.php.net to get a copy of this message | ||
From: daimona dot wiki at gmail dot com
Operating system: Any
PHP version: Irrelevant
Package: Scripting Engine problem
Bug Type: Bug
Bug description:error_reporting() and ini_get('error_reporting') can get out of sync using
@
Description:
------------
This bug is a direct consequence of bug #75924. That one essentially
states that, starting with PHP 7, the @ operator affects the output of
error_reporting(), but not that of ini_get('error_reporting').
Now, consider the following test case: https://3v4l.org/70QJY
For the PHP 7 examples, I'd expect error_reporting() and ini_get() to
return the same value (-1) in "POST", but this is not the case.
AIUI, it happens because:
- error_reporting() and ini_get() are out of sync when testFunc()
starts, per bug #75924
- error_reporting(0) syncs them again, as expected
- Same for error_reporting($orig)
- But then, when the silenced statement ends, only error_reporting() is
restored (because only error_reporting() was changed by @, I guess)
This bug affects all versions of PHP starting from 7.0. PHP 8 is also
affected, even though some numeric values are different.
Test script:
---------------
function testFunc() {
print "INSIDE 1 er=" . error_reporting() . ' ini=' . intval(
ini_get( 'error_reporting' ) ) . "\n";
$orig = error_reporting( 0 );
print "INSIDE 2 er=" . error_reporting() . ' ini=' . intval(
ini_get( 'error_reporting' ) ) . "\n";
error_reporting( $orig );
print "INSIDE 3 er=" . error_reporting() . ' ini=' . intval(
ini_get( 'error_reporting' ) ) . "\n";
}
print "PRE er=" . error_reporting() . ' ini=' . intval( ini_get(
'error_reporting' ) ) . "\n";
@testFunc();
print "POST er=" . error_reporting() . ' ini=' . intval( ini_get(
'error_reporting' ) ) . "\n";
Expected result:
----------------
PRE er=-1 ini=-1
INSIDE 1 er=0 ini=0
INSIDE 2 er=0 ini=0
INSIDE 3 er=0 ini=0
POST er=-1 ini=-1
Actual result:
--------------
PRE er=-1 ini=-1
INSIDE 1 er=0 ini=-1
INSIDE 2 er=0 ini=0
INSIDE 3 er=0 ini=0
POST er=-1 ini=0
--
Edit bug report at https://bugs.php.net/bug.php?id=81454&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81454&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81454&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81454&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81454&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81454&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81454&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81454&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81454&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81454&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81454&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81454&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81454&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81454&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81454&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81454&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81454&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81454&r=mysqlcfg