Bug #75693 [Opn->Ver]: ArrayObject does not set dynamic values up from 7.1.4
| From: | nikic@php.net | Date: | Sat, 16 Dec 2017 17:07:44 +0000 |
| Subject: | Bug #75693 [Opn->Ver]: ArrayObject does not set dynamic values up from 7.1.4 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213132@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75693&edit=1
ID: 75693
Updated by: nikic@php.net
Reported by: kodeart at gmail dot com
Summary: ArrayObject does not set dynamic values up from
7.1.4
-Status: Open
+Status: Verified
Type: Bug
Package: SPL related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This is due to the fix for bug #74058. The problem is that your offsetGet() method simply
wasn't called previously (for this specific code). Now it is called, but does not work
correctly, because offsetGet() needs to return by reference to support indirect array modification.
You'd need something like this instead: https://3v4l.org/ZofH7
Unfortunately this doesn't work either, because ArrayObject::offsetGet() itself does not return
by reference. We can't easily change it to return by reference, because that would require all
classes extending ArrayObject to do so as well, which would be a BC break.
Previous Comments:
------------------------------------------------------------------------
[2017-12-15 17:12:20] kodeart at gmail dot com
Description:
------------
The dynamic key/values in ArrayObject are not set starting from v7.1.4 (up to 7.2.0) when the key
does not exists and the value is array (nested or otherwise).
The overridden ArrayObject methods in the class exists to provide a fluid interface (for offsetSet)
and return the value or NULL as a special case (for offsetGet). It's not the best logic but the
behavior is expected to be consistent in all (or at least) PHP 7.1 versions.
Test script:
---------------
https://3v4l.org/LQdPJ
Expected result:
----------------
The behavior should be consistent in all versions.
Actual result:
--------------
At the time of this report the dynamic key/value is
- set in 5.6.0 - 5.6.30, 7.0.0 - 7.1.3
- not set up from 7.1.4 - 7.2.0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75693&edit=1