Edit report at https://bugs.php.net/bug.php?id=79822&edit=1
ID: 79822
Comment by: stsalkov at gmail dot com
Reported by: wadih at systemesmw dot com
Summary: Opcache and get_class_vars() - first output correct,
subsequent outputs wrong
Status: Open
Type: Bug
Package: opcache
Operating System: Ubuntu
PHP Version: 7.4.3
Block user comment: N
Private report: N
New Comment:
Can confirm this on a vanilla Ubuntu 20.04LTS install (Apache/2.4.41, PHP 7.4.3).
Previous Comments:
------------------------------------------------------------------------
[2020-07-09 13:44:49] wadih at systemesmw dot com
update summary
------------------------------------------------------------------------
[2020-07-09 13:42:46] wadih at systemesmw dot com
Description:
------------
The same call to get_class_vars() prints different values depending if it's the first time I
run it, or if it's subsequent times, when opcache is on which is on by default. (See code in
Test script)
First time, e.g. http://localhost/mytest.php, it prints:
7.4.3
Array
(
[v] => a
)
Array
(
[v] => b
)
Refresh the page, now prints:
7.4.3
Array
(
[v] => a
)
Array
(
[v] => a
)
Any subsequent refreshes prints [v] => a
Now slightly modify the PHP page to trigger a change , and it prints:
7.4.3
Array
(
[v] => a
)
Array
(
[v] => b
)
Refresh the page, and goes back to:
7.4.3
Array
(
[v] => a
)
Array
(
[v] => a
)
And subsequent refreshes still print [v] => a
SOLUTION:
Set opcache.enable=0 in php.ini, restart apache2. Bug disappears, and prints [v] => b each time
now.
VERSIONS:
Apache/2.4.41 (Ubuntu)
PHP 7.4.3 (cli)
libapache2-mod-php 2:7.4+75
Test script:
---------------
class MyClass {
public static $v = 'a';
}
echo '<pre>';
echo phpversion() . "\n";
print_r(get_class_vars('MyClass'));
MyClass::$v = 'b';
print_r(get_class_vars('MyClass'));
Expected result:
----------------
7.4.3
Array
(
[v] => a
)
Array
(
[v] => b
)
Actual result:
--------------
7.4.3
Array
(
[v] => a
)
Array
(
[v] => a
)
// Note, it is correct only first time it is run, but wrong all subsequent times, when opcache is
active
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79822&edit=1