ServiceClosureArgument with private service references original non-existent service

Created on 5 October 2023, 9 months ago
Updated 12 October 2023, 9 months ago

Problem/Motivation

When using the recently implemented-in-Drupal \Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument ( ✨ Support ServiceClosureArgument in \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::dumpValue Fixed ) where the referenced service is a private service, when accessing in runtime an error is thrown. The error references the original privatized service ID. However this service is not accessible (does not exist with the given ID).

Example real world issue.

Take for example the Symfony Scheduler component. This component constructs a scheduler.messenger_transport_factory service where the first arg is a ServiceLocatorArgument (via \tagged_locator()).

The services that are given to it are all private services. These services are built from classes tagged with \Symfony\Component\Scheduler\Attribute\AsSchedule. Which are then created as services and programmatically tagged with scheduler.schedule_provider via registerAttributeForAutoconfiguration

When the ServiceLocator intended for scheduler.messenger_transport_factory tries to access one of the services by original ID via closure it cannot. Errors such as this are thrown:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
You have requested a non-existent service "messenger.transport.foobar".

Steps to reproduce

Above example, or.

Build a service locator which references private IDs.

The service locator should be able to reference services by original ID.

Proposed resolution

???

Remaining tasks

User interface changes

Nil.

API changes

Fixes gap in SymfonyClosureArgument implementation

Data model changes

Nil.

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024