Skip to content

[DI] Fix resolving env vars when compiling a ContainerBuilder #23940

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

Merged
merged 1 commit into from
Aug 21, 2017

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

As spotted by @ro0NL, $container->compile(true) doesn't resolve direct env var references found in service definitions. Fixed here.

/**
* Replaces env var placeholders by their current values.
*/
class ResolveEnvPlaceholdersPass extends AbstractRecursivePass
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation is similar to the one in ResolveParameterPlaceHoldersPass

/**
* Replaces "%env(FOO)%" references by their placeholder, keeping regular "%parameters%" references as is.
*/
public function resolveEnvReferences(array $value)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has been introduced a few days ago, never released yet - thus no BC break here.

@ro0NL
Copy link
Contributor

ro0NL commented Aug 21, 2017

@nicolas-grekas i reproduced the array-to-string conversion on 3.3 with $_ENV['REAL'] = array().

That now produces Illegal offset type in isset or empty in ContainerBuilder.php:1418. Considering getEnv returns mixed, it might need a patch :) The str_ireplace call seems fine looking at code.

The mixed runtime/compiletime works great now, inlucding leaving out default and/or real values. It just works as expected 👍

@nicolas-grekas
Copy link
Member Author

array-to-string conversion

fixed, should be good then

@nicolas-grekas nicolas-grekas merged commit 9219594 into symfony:3.3 Aug 21, 2017
nicolas-grekas added a commit that referenced this pull request Aug 21, 2017
…der (nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[DI] Fix resolving env vars when compiling a ContainerBuilder

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

As spotted by @ro0NL, `$container->compile(true)` doesn't resolve direct env var references found in service definitions. Fixed here.

Commits
-------

9219594 [DI] Fix resolving env vars when compiling a ContainerBuilder
@nicolas-grekas nicolas-grekas deleted the fix-env-resolve branch August 21, 2017 16:07
@fabpot fabpot mentioned this pull request Aug 28, 2017
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.

3 participants