Bug #81652 [NEW]: The value of error_reporting() gets overridden

From: Date: Tue, 23 Nov 2021 11:45:31 +0000
Subject: Bug #81652 [NEW]: The value of error_reporting() gets overridden
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237939@lists.php.net to get a copy of this message
From:             joupicky at gmail dot com
Operating system: Ubuntu 20.04.3 LTS
PHP version:      8.0.13
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:The value of error_reporting() gets overridden

Description:
------------
The value of error_reporting() function (and global error reporting
setting) gets overridden when a native PHP function such as random_int()
or filemtime() gets called with a suppress "@" operator and assigned to
a class variable.

I am running PHP Version 8.0.13 with the latest Apache2. I was able to
reproduce this also when ran as FPM. I was not able to reproduce this
when called as CLI. I am using a precompiled binaries from
https://launchpad.net/~ondrej/+archive/ubuntu/php/.
I was not able to
reproduce this on PHP7.4 when install via Ubuntu repos. This might be
only relevant to the build from that repository (which is used by many
people AFAIK).

Test script:
---------------
<?php

error_reporting(E_ALL);

class Foo
{
    public $a;

    public function bar() {
        $this->a = (true) ? @random_int(0, 100) : false;
    }
}

var_dump(error_reporting()); //int(32767) = E_ALL
$c = new Foo();

$c->bar();

var_dump(error_reporting()); //random int

Expected result:
----------------
int(32767)
int(32767) 

Actual result:
--------------
int(32767)
int(5) //random int

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81652&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81652&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81652&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81652&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81652&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81652&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81652&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81652&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81652&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81652&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81652&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81652&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81652&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81652&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81652&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81652&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81652&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81652&r=mysqlcfg


Thread (10 messages)

« previous php.bugs (#237939) next »