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

Introduce __unserialize behaviour in docs #9390

Merged
merged 3 commits into from
Jan 30, 2022
Merged

Introduce __unserialize behaviour in docs #9390

merged 3 commits into from
Jan 30, 2022

Conversation

SenseException
Copy link
Member

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/EQ90P

It probably needs a link to the the new methods and maybe a more detailed description about how it should be handled.

Comment on lines 88 to 90
- 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.
Copy link
Member

@derrabus derrabus Jan 17, 2022

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.

Copy link
Member Author

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().

@derrabus derrabus added this to the 2.11.1 milestone Jan 30, 2022
@derrabus derrabus merged commit 4b88ce7 into doctrine:2.11.x Jan 30, 2022
derrabus added a commit to derrabus/orm that referenced this pull request Jan 30, 2022
* 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)
derrabus added a commit to derrabus/orm that referenced this pull request Jan 30, 2022
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants