laminas / laminas-stdlib

SPL extensions, array utilities, error handlers, and more
https://docs.laminas.dev/laminas-stdlib/
BSD 3-Clause "New" or "Revised" License
190 stars 40 forks source link

[3.6] Regression: ArrayObject with protected ARRAY_AS_PROPS cannot be serialized anymore #39

Closed Slamdunk closed 2 years ago

Slamdunk commented 2 years ago
Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC yes/no
QA yes/no

Description

In our app we serialize Laminas\Session\Storage\ArrayStorage objects as defined in its package: https://github.com/laminas/laminas-session/blob/2.12.0/src/Storage/ArrayStorage.php Which uses ArrayObject::ARRAY_AS_PROPS alongside a protected property $isImmutable.

Such serialization broke after https://github.com/laminas/laminas-stdlib/pull/35 has been released in 3.6 minor.

The proposed test indeed passes on 3.5.x branch.

I hope to find a fix soon, in the meantime I'd like to know if such BC Break was intended or not, ping @weierophinney

Surely a BC Break that deserves a bugfix release, imho.

Slamdunk commented 2 years ago

Here's the bug explained: child class properties are serialized before parent's ones. So __set is called on child property before setFlags can be properly filled, in the 3.6.0 foreach loop. This PR, just like 3.5 branch, sets ArrayObject very properties before any other __set call.