Skip to content

Code Modernization: Address __wakeup() deprecation in PHP 8.5. - #825

Closed
TobiasBg wants to merge 1 commit into
Freemius:masterfrom
TobiasBg:patch-2
Closed

Code Modernization: Address __wakeup() deprecation in PHP 8.5.#825
TobiasBg wants to merge 1 commit into
Freemius:masterfrom
TobiasBg:patch-2

Conversation

@TobiasBg

Copy link
Copy Markdown

PHP 8.5 deprecates the __sleep() and __wakeup() magic methods in favor of __serialize() and __unserialize().

See https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods

For PHP < 7.4 compatibility, __sleep() and __wakeup() need to be kept for the time being.

This commit moves the logic of the __wakeup() method to __unserialize(), and turns the former into a wrapper. The SDK does not use __sleep() methods, so this is the only change required.

PHP 8.5 deprecates the `__sleep()` and `__wakeup()` magic methods in favor of `__serialize()` and `__unserialize()`.

See https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods

For PHP < 7.4 compatibility, `__sleep()` and `__wakeup()` need to be kept for the time being.

This commit moves the logic of the `__wakeup()` method to `__unserialize()`, and turns the former into a wrapper. The SDK does not use `__sleep()` methods, so this is the only change required.
@TobiasBg

Copy link
Copy Markdown
Author

Ok, this might need some more code to actually restore properties, see the ongoing discussion at https://core.trac.wordpress.org/ticket/63962#comment:11 and following comments.

@swashata

swashata commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

@TobiasBg looks like the deprecation was cancelled (like you said so in the ticket) https://wiki.php.net/rfc/soft-deprecate-sleep-wakeup

And we tried out an implementation here in #831 The implementation worked but it produced more boilerplate code (the exact reason for which the deprecation was cancelled).

So I am also closing this as wontfix for now. If the deprecation ever becomes real we can revisit.

@TobiasBg

TobiasBg commented Nov 2, 2025

Copy link
Copy Markdown
Author

Hi @swashata!
Yes, good call, this can be wontfixed with the deprecation having been removed.
Totally forgot to update/close this PR as well, sorry.

@TobiasBg
TobiasBg deleted the patch-2 branch November 2, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants