[wp-trac] [WordPress Trac] #63962: PHP 8.5: Fix deprecation notices for __sleep and __wakeup magic methods

WordPress Trac noreply at wordpress.org
Wed Sep 24 20:02:57 UTC 2025


#63962: PHP 8.5: Fix deprecation notices for __sleep and __wakeup magic methods
-------------------------------------------+-------------------------------
 Reporter:  TobiasBg                       |       Owner:  SergeyBiryukov
     Type:  defect (bug)                   |      Status:  reopened
 Priority:  normal                         |   Milestone:  6.9
Component:  General                        |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  php85 has-patch needs-testing  |     Focuses:  php-
                                           |  compatibility
-------------------------------------------+-------------------------------
Changes (by desrosj):

 * keywords:  php85 has-patch => php85 has-patch needs-testing
 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 I think that [60796] is causing an issue. Here is what I've been able to
 determine so far.

 Previously, because there was no `__unserlialize()` method, the data was
 restored using `unserialize()`. However, now that the magic method is
 present, that method completely replaces the default behavior. Because of
 this, the properties that are checked are always empty/not set when
 `__unserialize()` is invoked.

 For example, in `WP_Block_Patterns_Registry`, `$registered_patterns`
 property is always empty and the first conditional check will always
 `return` early.

 In classes where actual logic was moved into `__unserialize()` (this
 should not matter for any that throw a `LogicException` should), the logic
 needs to be updated to restore the passed data from the `$data` parameter
 before performing checks for the presence or datatype of the expected
 properties.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63962#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list