Deal with PHP 8.5 depration of __sleep()/__wakeup()

Created on 26 September 2025, 7 days ago

Problem/Motivation

The methods are deprecated in favour of __[un]serialize() and symfony alredy fixed it

But core has wider usage overriding seriazed keys, especially in container serialization.

New approach (since PHP 7.4) is using https://wiki.php.net/rfc/custom_object_serialization and since PHP 8.1 using the Serializable interface is deprecated without magic methods

Steps to reproduce

See core's unit tests using PHP 8.5 in latest pipelines

Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /builds/issue/drupal-3548957/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php on line 12
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in /builds/issue/drupal-3548957/core/lib/Drupal/Core/Database/Connection.php on line 29
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in /builds/issue/drupal-3548957/core/lib/Drupal/Core/Cache/MemoryBackend.php on line 23

Proposed resolution

- replace methods as suggested
- provide BC
- write CR

Remaining tasks

- create MR from changes

WIP sleep wakeup __unserialize

and next for BC https://git.drupalcode.org/project/drupal/-/merge_requests/12877/commits

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

base system

Created by

🇫🇷France andypost

Live updates comments and jobs are added and updated live.
  • PHP 7.4

    The issue particularly affects sites running on PHP version 7.4.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024