Bug #79822 [NEW]: Opcache get_class_vars() - first run successful, subsequent runs wrong
From: wadih at systemesmw dot com
Operating system: Ubuntu
PHP version: 7.4.7
Package: opcache
Bug Type: Bug
Bug description:Opcache get_class_vars() - first run successful, subsequent runs wrong
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 bug report at https://bugs.php.net/bug.php?id=79822&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79822&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79822&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79822&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79822&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79822&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79822&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79822&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79822&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79822&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79822&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79822&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79822&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79822&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79822&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79822&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79822&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79822&r=mysqlcfg
Thread (8 messages)
- wadih at systemesmw dot com
- wadih at systemesmw dot comBug #79822 [Opn]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
- stsalkov at gmail dot comBug #79822 [Com]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
- cmb@php.netBug #79822 [Opn->Ver]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
- nikic@php.netBug #79822 [Ver]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
- stsalkov at gmail dot comBug #79822 [Com]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
- nikic@php.netBug #79822 [Ver]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
- nikic@php.netBug #79822 [Ver->Csd]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong