-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Introduce __unserialize behaviour in docs #9390
Conversation
docs/en/reference/architecture.rst
Outdated
- PHP 7.4 introduces the new magic method ``__unserialize``, which changes the execution | ||
priority between ``__wakeup`` and itself when used. This can cause unexpected behaviour in | ||
an Entity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd simply apply the same warning as for __wakeup()
because effectively __unserialize()
replaces __wakeup()
if it's present.
Also, we should remove the recommendation to implement Serializable
because that interface is considered deprecated. And cookbook/implementing-wakeup-or-clone
might need adjustments as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. __unserialize()
isn't something that can be added lightly to an entity, but should we discourage from using it as long as ORM can't use this method in entities? Currently it shouldn't be used there. I expect that a future version will deprecate __wakeup()
in favour of __unserialize()
.
* 2.12.x: Introduce __unserialize behaviour in docs (doctrine#9390) Adapt test logic to PHP and SQLite II (doctrine#9442) Use the identify generator strategy Added php 8.1 to CI Psalm 4.19.0, PHPStan 1.4.3 (doctrine#9438) Ignore PHPUnit result cache everywhere (doctrine#9425)
* 2.12.x: Introduce DoctrineSetup as a replacement for Setup (doctrine#9443) Introduce __unserialize behaviour in docs (doctrine#9390) Adapt test logic to PHP and SQLite II (doctrine#9442) Use the identify generator strategy Added php 8.1 to CI Psalm 4.19.0, PHPStan 1.4.3 (doctrine#9438) Ignore PHPUnit result cache everywhere (doctrine#9425)
I'm not sure about the detail in which this should be described in the docs, which is why the first change is another list entry.
This PR mentions the magic method
__unserialize()
in entities.__wakeup
is already considered a problem when used in an entity and__unserialize()
introduces a new behaviour that should be mentioned in the docs: https://3v4l.org/EQ90PIt probably needs a link to the the new methods and maybe a more detailed description about how it should be handled.