fix: correct interpretation of environment variables #187
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a problem with the interpretation of environment variables in the current system.
When we want to add an environment variable in the configuration file currently like this:
Only the "allow_origin" key works because there is no processing done behind the user's back.
On the other keys, a treatment is applied (putting everything in upper or lower case).
Only when you want to add an environment variable, this is automatically managed by Symfony in the form of a hash.
However, when these modifications are made to our values (which are actually environment variable keys) this modifies the key and Symfony no longer finds the associated value.
For example, our "%env(CORS_ALLOW_HEADERS)%" key becomes "env_588d27cb6d976748_string_CORS_ALLOW_ORIGIN_717607a427d05ca1694bd72e43dce0ea" at the time of interpretation by Symfony, but is later transformed by the bundle into "env_588d27cb6d976748_string_cors_allow_origin_717607a427d05ca1694bd72e43dce0ea" (all lowercase). And the Symfony, no longer knows how to return the value of this key.
The idea to resolve the problem and to be able to use environment variables everywhere, is to test if they can be solved with the "resolveEnvPlaceholders" function of Symfony. If so, we leave as is, otherwise we add the filter.