-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] when@{env} does not work on imported files #41584
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
Comments
Can you please provide a reproducer or maybe a failing test case? |
Yes, I'm working on it 👍 |
I've created a reproducer: https://github.com/nusje2000/symfony-41584-reproducer. See https://github.com/nusje2000/symfony-41584-reproducer/runs/2764838070 for the failing test result. @nicolas-grekas I think I know how to fix this issue, so if you think this is a bug as well, I can open a PR. |
Please do yes! |
nicolas-grekas
added a commit
that referenced
this issue
Jun 8, 2021
…es (nusje2000) This PR was submitted for the 5.4 branch but it was squashed and merged into the 5.3 branch instead. Discussion ---------- [DependencyInjection] fix `when@{env}` inside imported files | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | Tickets | Fix #41584 | License | MIT This PR enables users to use the `when@{environment}` in imported files. I found that the env was explicitly unset when loading the file (including its imports) which resulted in the environment not being set when processing the imports. See https://github.com/nusje2000/symfony-41584-reproducer for a reproduction of the problem. Commits ------- 18fe0dd [DependencyInjection] Removed unsetting of environment property in loaders
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected: ^5.3.0
Description
When using the new feature for defining multiple environments in a single config files, you cannot import a file containing the
when@{env}
key. Although it is valid, it won't be used. Within the YamlFileLoader I found that when importing the files the environment property is temporary unset and is restored after finishing the import.I don't know if this is an actual bug since it looks like this feature is not available in imported files on purpose.
How to reproduce
config.yml
profiler.yml
Possible Solution
I looked at the YamlFileLoader and discovered that the environment was unset after loading the initial file (containing the import). I think it should be possible to remove this logic and have it work in imports too.
The text was updated successfully, but these errors were encountered: