Bug #79822 [Opn]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong

From: Date: Thu, 09 Jul 2020 13:44:49 +0000
Subject: Bug #79822 [Opn]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227920@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79822&edit=1 ID: 79822 User updated by: wadih at systemesmw dot com Reported by: wadih at systemesmw dot com -Summary: Opcache get_class_vars() - first run successful, subsequent runs wrong +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.7 +PHP Version: 7.4.3 Block user comment: N Private report: N New Comment: update summary Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#227920) next »