Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DependencyInjection: added missing use $container #37665

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
wants to merge 1 commit into from
Closed

DependencyInjection: added missing use $container #37665

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 25, 2020

Q A
Branch? 5.1
Bug fix? yes
New feature? no
Deprecations? no

If you use not shared services, $container was not shared in closure. Error-Message: Notice: Undefined variable: $container

@nicolas-grekas
Copy link
Member

As highlighted in the failing test case, there are situations where the use should not be dumped.
Can you please provide a test case that fails? If not, can you provide a reproducer instead?

@nicolas-grekas nicolas-grekas added this to the 5.1 milestone Jul 29, 2020
@ghost
Copy link
Author

ghost commented Jul 29, 2020

Hi Nicolas,

Of course. Here you can will find an example project.

https://github.com/DarkyMuc/symfony_di_example
composer install
symfony server:start -port 8001

After you call this project via browser, you receive the error "Notice: Undefined variable: container"

I think it's the combination of shared: false and lazy: true in the service.yaml.

Greetings Markus

@nicolas-grekas
Copy link
Member

Thanks for all the details, fixed in #37953

fabpot added a commit that referenced this pull request Aug 26, 2020
This PR was merged into the 5.1 branch.

Discussion
----------

[DI] fix dumping lazy non-shared services

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

Commits
-------

a4f4ca7 [DI] fix dumping lazy non-shared services
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants