Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
From: cmb@php.net Date: Tue, 30 Nov 2021 14:24:31 +0000 Subject: Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1 References: 1 Groups: php.doc.bugs Request: Send a blank email to doc-bugs+get-19348@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81675&edit=1
ID: 81675
Updated by: cmb@php.net
Reported by: diede at yoast dot com
Summary: Undocumented change in get_class_vars behaviour with
static properties in 8.1
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Scripting Engine problem
PHP Version: 8.1.0
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2021-11-30 14:11:42] nikic@php.net
As the behavior was there for quite a long time, adding a note for buggy behavior with PHP < 8.1
without opcache seems reasonable.
------------------------------------------------------------------------
[2021-11-30 13:40:12] bugs dot php dot net_nospam at adviesenzo dot nl
> I'm not sure whether this should be documented,
given that OPcache is likely always enabled in production
environments at least.
Well, considering it took us a not insignificant amount of time to pin down what was causing the
difference in behaviour and that the change removes a difference between typical production vs
develop environments which people may have run into and got stuck on trying to figure out before, I
think documenting this would be useful, if for no other reason than to save other people running
into the same/similar situation debug time.
------------------------------------------------------------------------
[2021-11-30 12:21:28] cmb@php.net
3v4l.org runs without OPcache. With OPcache enabled, you already
got the same result as with PHP 8.1. This inconsistency[1] has
now been fixed[2]; I'm not sure whether this should be documented,
given that OPcache is likely always enabled in production
environments at least.
[1] <https://bugs.php.net/bug.php?id=80821>
[2] <https://github.com/php/php-src/commit/3eb97a456648c739533d92c81102cb919eab01c9>
------------------------------------------------------------------------
[2021-11-30 10:56:38] diede at yoast dot com
Description:
------------
I have a feeling that get_class_vars() received a bugfix. Previously it included the
current value of a static property, but now returns the default/initial value instead. This now
matches the documentation, but the behaviour of previous PHP versions didn't match the
documentation.
I can't find anything in the changelogs, docs and RFCs. Here's where we looked:
- https://github.com/php/php-src/blob/php-8.1.0/UPGRADING
- https://www.php.net/manual/en/migration81.php
- https://www.php.net/manual/en/function.get-class-vars.php
- https://wiki.php.net/rfc#php_81
- https://github.com/php/php-src/blob/php-8.1.0/NEWS
This could at the very least be considered a breaking change and should be documented.
Test script:
---------------
<?php
// https://3v4l.org/RjVk0
class MyClass {
public static $myProperty;
}
MyClass::$myProperty = 3;
var_dump( get_class_vars( MyClass::class ) );
Expected result:
----------------
// Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13
array(1) {
["myProperty"]=>
int(3)
}
Actual result:
--------------
// Output for 8.1.0
array(1) {
["myProperty"]=>
NULL
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81675&edit=1
Thread (9 messages)
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Unknown Message
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Opn->Ver]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
- Doc #81675 [Com]: Undocumented change in get_class_vars behaviour with static properties in 8.1
| « previous | php.doc.bugs (#19348) | next » |
|---|