8000 Access the annotation_reader public service triggers an error · Issue #46202 · symfony/symfony · GitHub
[go: up one dir, main page]

8000 Skip to content
Access the annotation_reader public service triggers an error #46202
Closed
@stof

Description

@stof

Symfony version(s) affected

4.4.39+, 5.4.6+

Description

ca56620 changed the way the cached annotation reader is managed in the late compiler pass AddAnnotationsCachedReaderPass

But making the annotations.cached_reader service public during optimizations and turning it private after them breaks the expectations of the optimizations themselves (a public alias pointing to a public service does not get optimized the same than a public alias pointing to a private service).
The annotation_reader service is the only service for which we do such weird thing to allow using that service (without caching) while the container is being built.
But we should really have a functional test ensuring that the logic does not break the public access to the service.

How to reproduce

Put that in a WebTestCase (or change the way to get a booted kernel):

        self::bootKernel();

        $annotationReader = self::$kernel->getContainer()->get('annotation_reader');

This is producing an error because the compiled container optimized the annotation_reader alias in a way relying on the fact that annotations.cached_reader would be public, but this changed after.

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "annotations.cached_reader" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0