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

[9.x] Remove __sleep() & __wakeup() from SerializesModels trait. #44847

Merged
merged 1 commit into from
Nov 6, 2022

Conversation

r-kujawa
Copy link

@r-kujawa r-kujawa commented Nov 5, 2022

This PR removes support for the __sleep() & __wakeup() methods in the SerializesModels trait, since they have become irrelevant in Laravel 9.x as the minimum requirements are PHP 8.0. In this version of PHP the __serialize() method will be called instead of the __sleep() method and the __unserialize() method will be called instead of the __wakeup() method.

I believe the reason why both magic methods were still present in this trait was to keep supporting PHP 7.3 in Laravel 8.x.

Documentation reference

@r-kujawa r-kujawa force-pushed the 9.x-remove_sleep_and_wakeup branch from a33a6bb to a5ce9e5 Compare November 5, 2022 05:45
@r-kujawa r-kujawa changed the title Remove __sleep & __wakeup from SerializesModels trait. [9.x] Remove __sleep() & __wakeup() from SerializesModels trait. Nov 5, 2022
@taylorotwell taylorotwell merged commit 033b956 into laravel:9.x Nov 6, 2022
joeyrush pushed a commit to Nutickets/laravel-actions that referenced this pull request Feb 21, 2023
@adrianspacely
Copy link
Contributor

Really wish this was targeted at Laravel 10 given methods were removed. 🤦

@driesvints
Copy link
Member

@adrianb93 but these methods aren’t used anymore.

@adrianspacely
Copy link
Contributor

Just a bit of a deployment panic. A package we use referenced it and some of our code also used this trait and had it's own __sleep method.

@driesvints
Copy link
Member

It was never meant for these methods to be overwritten. We can't protect against everything people do in userland.

bjuppa added a commit to kontenta/kontour that referenced this pull request Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants