Problem/Motivation
I'm not sure if this is a bug, because I'm not sure if Drupal ever intended to support symfony lazy services, but I noticed that if someone marks a dependency as lazy, it will not be serialized by DependencySerializationTrait.
Steps to reproduce
- Mark an autowired service dependency as lazy, e.g.
#[Autowire(service: 'event_dispatcher', lazy: true)] - Add
use DependencySerializationTrait; - Try to serialize() it.
- The lazy service dependency will not be processed by DependencySerializationTrait because
$reverse_container->getId($value)returns NULL.
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3613685
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mfbFixing copy/paste error
Comment #4
hoxton commentedas per Drupal Doc i think calling serialization on dependent service even if they were marked lazy, shall be treated as a use and should add the service as a whole and give valid serialization.
Comment #5
hoxton commented@mfb, i tried to replicate this issue on local with given step and was not able do so. Can you please update in what context this happened and what you used to get this issue.