Bug #79822 [Ver->Csd]: Opcache and get_class_vars() - first output correct, subsequent outputs wrong
| From: | nikic@php.net | Date: | Tue, 30 Nov 2021 14:10:31 +0000 |
| Subject: | Bug #79822 [Ver->Csd]: 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-238061@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
Updated by: nikic@php.net
Reported by: wadih at systemesmw dot com
Summary: Opcache and get_class_vars() - first output correct,
subsequent outputs wrong
-Status: Verified
+Status: Closed
Type: Bug
Package: opcache
Operating System: Ubuntu
PHP Version: 7.4.3
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Closing as fixed in 8.1.
Previous Comments:
------------------------------------------------------------------------
[2021-07-23 08:00:46] nikic@php.net
After https://github.com/php/php-src/commit/3eb97a456648c739533d92c81102cb919eab01c9
the behavior will be consistently "a a" as previously with opcache, and in line with the
docs.
We could still change the behavior and docs though.
------------------------------------------------------------------------
[2020-07-14 17:46:40] stsalkov at gmail dot com
Since this behavior dates back to PHP 4, I think it'd be fair to say "the documentation is
wrong" rather than "the implementation is wrong." To me, the culture of not breaking
backwards compatibility has always been an important part of PHP.
In any case, it shouldn't behave differently depending on whether opcache is enabled.
------------------------------------------------------------------------
[2020-07-13 08:20:53] nikic@php.net
What is the expected behavior here? The docs say:
> Returns an associative array of declared properties visible from the current scope, with their
> default value. The resulting array elements are in the form of varname => value. In case of an
> error, it returns FALSE.
So based on that, and what the implementation does, the intention here was to return the default
values, not the current values. However, historically we don't even remember the default values
of static properties! In 7.4 we do if opcache is loaded, thus the change in behavior.
ReflectionClass::getDefaultProperties() is probably also affected.
------------------------------------------------------------------------
[2020-07-09 16:57:54] cmb@php.net
With the most recent PHP-7.4 from Git, I get the wrong result on
CLI (Windows) with OPcache enabled right away on the first run.
This may have the same root cause as bug #79487.
------------------------------------------------------------------------
[2020-07-09 13:56:12] stsalkov at gmail dot com
Can confirm this on a vanilla Ubuntu 20.04LTS install (Apache/2.4.41, PHP 7.4.3).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=79822
--
Edit this bug report at https://bugs.php.net/bug.php?id=79822&edit=1