-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Remove hasty verification of unused env variables #22726
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
Conversation
@@ -1080,6 +1080,8 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs | |||
/** | |||
* Get statistics about env usage. | |||
* | |||
* @deprecated unused and must be removed in some next release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Symfony 4.0, deprecated since 3.4
@@ -1080,6 +1080,8 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs | |||
/** | |||
* Get statistics about env usage. | |||
* | |||
* @deprecated unused and must be removed in some next release | |||
* | |||
* @return int[] The number of time each env vars has been resolved | |||
*/ | |||
public function getEnvCounters() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should add a @trigger_error()
call here
Instead of throwing an Another option would be to not trigger the error if that field gets overridden by an extending yaml (import resource). |
π see the thread you linked: this was done on purpose. Env vars are no supposed to be allowed in every config options/parameters. So this error tells you when you did such mistake. |
Here is a use case of environment variables in config that is not a mistake, but produces an error. symfony_prod.yml
symfony_prod_ecs.yml
Error:
|
If you change your config to this, does it fix the issue? Removing a generic check to prevent a specific false positive (I agree it can be seen as such) is too broad (I didn't think about a more specific fix). I'm still -1 with the current patch. symfony_prod_ecs.yml
|
Sorry, I should have pointed out that even |
Confirmed. Even if you use This means that we cannot use environment variables in a config.yaml if you ever need to override, swap or un-use that environment variable in any extending config(s). |
OK, thanks. This PR is too broad, we should seek for a more specific fix. |
Closing as explained. Issue #23520 should be used to track the progress on this topic instead. |
Hello,
After handling with problems reported on the issue #22561 and thinking about it, I decided to open this PR removing the verification that forces the use of every environment variable that was written at least once in some configuration file.
The code I want to remove was introduced in the PR #19681 that adds a nice and new feature, but in my opinion the verification of unused environment variables is hasty.
If there is some good argument to keep that verification, it should be done in a class that aims with the logic of the Dependency Injection component, not in a dumper class.
However, my vision is that the DI component MUST NOT force the use of any configuration set by the developer, because it is not matter of DI. If the developer wrote something unnecessary or wrong, it should be caught by environment tests after or during the build step.
Thank you.