Version: 2.0.1
Drupal Core: 11.2.8
Problem
When editing views in the Views UI, Drupal throws a fatal error: Exception: Serialization of 'Closure' is not allowed in serialize().
This occurs because Views UI attempts to cache the view configuration, which includes the StringManager service. StringManager has injected
dependencies (ThemeHandlerInterface, StringStorageInterface, CacheBackendInterface) that contain closures through the RequestStack service chain, which
cannot be serialized in PHP.
Proposed Resolution
Add DependencySerializationTrait to the StringManager class. This trait provides proper serialization handling by storing
only service IDs during serialization and re-injecting the actual services during unserialization, preventing the closure serialization error.
Steps to Reproduce
- Install String module 2.0.1 on Drupal 11.2.8
- Navigate to Structure > Views
- Attempt to edit any view (e.g., Content, Media, etc.)
- Error occurs:
Exception: Serialization of 'Closure' is not allowed in serialize() (line 14 of core/lib/Drupal/Component/Serialization/PhpSerialize.php)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | string-add-dependency-serialization-trait-3557845.patch | 780 bytes | mef |
Comments
Comment #2
mef commentedComment #3
mef commentedI was able to fix this using this patch. Yet I am unsure if there might be any implications or side effects I am not aware of.
Can somebody have a look and test this?
Thank you
Comment #4
mef commented