Skip to content

Lazy services in root namespace cannot be found #34863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bfeaver opened this issue Dec 6, 2019 · 4 comments
Closed

Lazy services in root namespace cannot be found #34863

bfeaver opened this issue Dec 6, 2019 · 4 comments

Comments

@bfeaver
Copy link

bfeaver commented Dec 6, 2019

Symfony version(s) affected: 4.4.0, 4.4.1

Description
After upgrading to 4.4.0 (and trying 4.4.1) when using a single container file, proxy classes for lazy services that have classes in the root namespace can't be found since the container file is in a generated namespace.

How to reproduce
Create a class without a namespace and use it as a lazy service in the container. Must be using the proxy-manager-bridge and container.dumper.inline_factories must be true.

Reproducer app: https://github.com/bfeaver/lazy-service-bug

All you'll need to do is:

$ composer install

When it does the Symfony cache warmup, it'll fail to find the TestService class.

Possible Solution
I traced it down to \Zend\Code\Generator\ClassGenerator::generateShortOrCompleteClassname() stripping off the leading backslash. If that method instead left it, there wouldn't be a problem. Maybe it would be possible to include the container's namespace as the currentNamespace in the ClassGenerator. Then it wouldn't match the final if condition in that method and it would add back the backslash to the class name.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 6, 2019

Could you please provide a small reproducer app? That'd help work on the issue.

@kricha
Copy link

kricha commented Dec 6, 2019

@nicolas-grekas i tkink it's related snc/SncRedisBundle#548

@bfeaver
Copy link
Author

bfeaver commented Dec 6, 2019

@nicolas-grekas Added the reproducer app to to the "How to reproduce" section above.

@nicolas-grekas
Copy link
Member

Thank you for the reproducer, fixed in #35049

nicolas-grekas added a commit that referenced this issue Dec 19, 2019
…classes (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[ProxyManager] fix generating proxies for root-namespaced classes

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34863
| License       | MIT
| Doc PR        | -

Commits
-------

a47ae10 [ProxyManager] fix generating proxies for root-namespaced classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants