Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Dec 7, 2021

Conversation

Slamdunk
Copy link
Contributor

@Slamdunk Slamdunk commented Nov 29, 2021

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 #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 Slamdunk force-pushed the array_object_as_props_bug branch from 8950302 to 3c31580 Compare November 29, 2021 14:38
… serialized anymore

Signed-off-by: Filippo Tessarotto <[email protected]>
Signed-off-by: Filippo Tessarotto <[email protected]>
@Slamdunk Slamdunk force-pushed the array_object_as_props_bug branch from 3c31580 to e330333 Compare November 29, 2021 14:42
Signed-off-by: Filippo Tessarotto <[email protected]>
Signed-off-by: Filippo Tessarotto <[email protected]>
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the context to review this, sorry.

I'd defer to @weierophinney, but you can pretty much assume that the BC break is not intentional, so a 3.6.x release is very much welcome, if it fixes the BC issue.

@@ -92,7 +92,7 @@ public function __isset($key)
}

if (in_array($key, $this->protectedProperties)) {
throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
throw new Exception\InvalidArgumentException("$key is a protected property, use a different key");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, these were changed by CS? :O

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 8 years these LoC are here in this very form 😄

@Slamdunk
Copy link
Contributor Author

Slamdunk commented Nov 29, 2021

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.

Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a tricky order of operations issue, and you're correct; the change was unintentional.

I've got a suggestion for your proposed solution which should also remove some of the new Psalm errors that were introduced.

src/ArrayObject.php Outdated Show resolved Hide resolved
Slamdunk and others added 2 commits December 1, 2021 07:35
Co-authored-by: Matthew Weier O'Phinney <[email protected]>
Signed-off-by: Filippo Tessarotto <[email protected]>
Signed-off-by: Filippo Tessarotto <[email protected]>
@Slamdunk Slamdunk force-pushed the array_object_as_props_bug branch from a387ed9 to d844fcf Compare December 1, 2021 06:36
Signed-off-by: Filippo Tessarotto <[email protected]>
@weierophinney weierophinney merged commit 6fe0842 into laminas:3.6.x Dec 7, 2021
@Slamdunk Slamdunk deleted the array_object_as_props_bug branch December 8, 2021 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants