Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the values of referenced env vars.#20618

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedNov 24, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

Being able to resolve environment variables at compile time as a replacement forSYMFONY__ special env vars, unlocking their deprecation (see#20100).

// generate a unique namespace for the given application
$env =$container->getParameter('kernel.root_dir').$container->getParameter('kernel.environment');
$env ='';
foreach (array('kernel.name','kernel.environment','kernel.debug','cache.prefix.seed')as$key) {
Copy link
Member

Choose a reason for hiding this comment

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

the kernel name, environment and debug don't need to resolve env parameters, as these are special parameters set by the Kernel itself (redefining them is not allowed, as the value set by the kernel will win anyway)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Doing so makes the code simpler. Do you think this can have any adverse side effect?

* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @return mixed The resolved value
*/
Copy link
Member

Choose a reason for hiding this comment

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

array $resolving = array() should not be exposed in the public API IMO. Use a private method for the recursive call

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This makes the resolution stateless.ParameterBag::resolveValue has the same strategy on this topic. I'd prefer keeping it this way.

Copy link
Member

@stofstofNov 24, 2016
edited
Loading

Choose a reason for hiding this comment

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

Well, I'm not talking about adding a private property. I'm talking about using a private methoddoResolveValue being exactly your currentresolveValue method (except for the renaming of course) and then having this for resolveValue:

publicfunctionresolveValue($value,$resolveEnvValues =false){return$this->doResolveValue($value,$resolveEnvValues,array());}

this way, we don't leak the internal argument to the public API (the fact that ParameterBag is leaking it is a mistake we made).

@nicolas-grekasnicolas-grekasforce-pushed thecontainer-resolve-value branch 5 times, most recently fromc5e3ef9 to9f55ad4CompareNovember 24, 2016 13:28
* Replaces parameter placeholders (%name%) and unescapes percent signs.
*
* @param mixed $value A value
* @param mixed $resolveEnvValues Whether %env(VAR)% parameters should be replaced by the value of the corresponding environment variable or not
Copy link
Member

Choose a reason for hiding this comment

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

should be boolean, not mixed

@nicolas-grekasnicolas-grekasforce-pushed thecontainer-resolve-value branch 2 times, most recently fromcc1bd7d to0a7ec76CompareNovember 24, 2016 20:32
@nicolas-grekasnicolas-grekasforce-pushed thecontainer-resolve-value branch 4 times, most recently from58d827e to6b7bf5cCompareNovember 29, 2016 21:46
@nicolas-grekasnicolas-grekas changed the title[DI] Add ContainerBuilder::resolveValue($value, $resolveEnvValues = false)[DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the value of referenced env vars.Nov 29, 2016
@nicolas-grekasnicolas-grekas changed the title[DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the value of referenced env vars.[DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the values of referenced env vars.Nov 29, 2016
@nicolas-grekasnicolas-grekas added this to the3.x milestoneDec 6, 2016
@nicolas-grekasnicolas-grekas modified the milestones:3.3,3.xDec 9, 2016
@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commit713b081 intosymfony:masterDec 17, 2016
fabpot added a commit that referenced this pull requestDec 17, 2016
…ble to inline the values of referenced env vars. (nicolas-grekas)This PR was merged into the 3.3-dev branch.Discussion----------[DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the values of referenced env vars.| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Being able to resolve environment variables at compile time as a replacement for `SYMFONY__` special env vars, unlocking their deprecation (see#20100).Commits-------713b081 [DI] Make ContainerBuilder::resolveEnvPlaceholders() able to inline the values of referenced env vars.
@nicolas-grekasnicolas-grekas deleted the container-resolve-value branchDecember 17, 2016 10:59
}
if ($container->hasParameter('cache.prefix.seed')) {
// Inline any env vars referenced in the parameter
$container->setParameter('cache.prefix.seed',$container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'),true));
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be done directly in theif above ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

technically, it's possible to define the param before the framework extension, which is handled with this style

@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

4 participants

@nicolas-grekas@fabpot@stof@javiereguiluz

[8]ページ先頭

©2009-2025 Movatter.jp