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

Deprecate the special SYMFONY__ environment variables#21889

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

Closed

Conversation

@javiereguiluz
Copy link
Member

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

@chalasr
Copy link
Member

I surely miss something but#20100 (comment):

shouldn't the Kernel::getEnvParameters() method be deprecated?

Or do we plan to trigger this deprecation forever?

@robfrawley
Copy link
Contributor

Vastly prefer the implementation described in#20100 (comment). I was going to comment on this earlier, but couldn't find that comment by@chalasr.

@javiereguiluz
Copy link
MemberAuthor

@chalasr about your comment, I don't agree on reporting the deprecation when using the env var instead of when setting it (if you set it, it's because you have defined it ... so you should get the deprecation).

About the other proposal ... I don't know what to say ... but others think it's much better, so if you can implement it, I guess we can close this PR in favor of your PR. Thanks!

@robfrawley
Copy link
Contributor

robfrawley commentedMar 12, 2017
edited
Loading

The reason I believe we shouldn't getany deprecations until an environment variable isactually used is because otherwise, we are restricting the use ofexternal environment variables without knowing that they are intended for consumption by Symfony itself. People may well be using environment variables beginning withSYMFONY__ for their own container port mapping or other functionality related to setting up their Symfony environment, but external to the Symfony runtime itself.

@chalasr
Copy link
Member

@javiereguiluz My point is mainly what@robfrawley said in the previous comment, but also that deprecatingSYMFONY__ prefixed env vars does not make sense to me in term of upgrade.
Defining these prefixed env vars will not stop to work, only using them as parameters will.
The symfony-specific behavior is only to consider these vars differently, I think the deprecation should reflect this and that this behavior should really die in 4.0 (i.e.Kernel::getEnvParameters() be removed).
I'll propose the alternative PR.

@javiereguiluz
Copy link
MemberAuthor

@chalasr yes, I agree that both of you are right and your solution is better than mine :) Thanks for providing the alternative PR. I'll close this one then.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedMar 14, 2017
edited
Loading

In think this implem here is right, but misses the deprecation ofKernel::getEnvParameters
The false positive that has been identified makes no harm at all: it's mainly theoretical, and it's not like it's going to break anything (4.0 won't throw - it'll just ignore and not warn anymore).

The alternative proposed in#21997 looks worse to me because it breaks SRP.

Until someone finds another solution freed from any of the identified drawbacks, I'm 👍 here (I won't be the one working on this as the identified drawback of this PR doesn't look that realistic to me.)

foreach ($_SERVERas$key =>$value) {
if (0 ===strpos($key,'SYMFONY__')) {
@trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %env()% syntax instead to get the value of environment variables in configuration files.',$key),E_USER_DEPRECATED);
$parameters[strtolower(str_replace('__','.',substr($key,9)))] =$value;
Copy link
Member

@chalasrchalasrMar 14, 2017
edited
Loading

Choose a reason for hiding this comment

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

%env()% should be%%env()%%

@javiereguiluz
Copy link
MemberAuthor

For the record, I still think that comments from Rob and Robin are right ... but I'll update this PR in case we don't find a viable alternative solution.

@nicolas-grekas
Copy link
Member

Reopening, this looks like the correct approach to me:

Defining these prefixed env vars will not stop to work, only using them as parameters will.

SYMFONY__ is not a common prefix. I'd better consider that we can claim triggering a deprecation notice here. In terms of DX, it's also way more important to me to warn users that if they expect aSYMFONY__ env var to be taken into account, then that won't happen in 4.0, even in the case they don't actually use it as params.

@chalasr
Copy link
Member

even in the case they don't actually use it as params.

If not used as a parameter then there is no reason to expect the env var to be taken into account. I don't understand how this is a better approach regarding DX, but let's move on.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedMar 14, 2017
edited
Loading

@chalasr since these env vars are used asdefault values, they can very well be defined by the env just in case - but actually not being used because the param is defined / not used by the current app.


/**
* @group legacy
* @expectedDeprecation The Symfony\Component\HttpKernel\Kernel::getEnvParameters() method is deprecated as of 3.3 and will be removed in 4.0. Use the %s syntax to get the value of any environment variable from configuration files instead.
Copy link
Member

Choose a reason for hiding this comment

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

The use of%env()% makes the assertion fails due to the use ofassertStringMatchesFormat. For now I didn't find better than replacing%env()% by%s in the expected deprecation to solve this issue

Choose a reason for hiding this comment

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

%c is a bit better :)

$parameters =array();
foreach ($_SERVERas$key =>$value) {
if (0 ===strpos($key,'SYMFONY__')) {
@trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.',$key),E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

not great but we have to exclude the special env vars which are set from the core:SYMFONY__REDIS_HOST is one (https://travis-ci.org/symfony/symfony/jobs/211006453)

Choose a reason for hiding this comment

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

or not use it anymore :)

chalasr, sstok, Taluu, and aecca reacted with thumbs up emojisstok and Taluu reacted with laugh emoji
@nicolas-grekas
Copy link
Member

missing entries in CHANGELOG / UPGRADE files

@fabpot
Copy link
Member

👍

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

A few comments, a rebase, and a test fix, then all good on my side.

which will tell the Kernel to use the response code set on the event's
response object.

* The`getEnvParameters()` method has been deprecated and will be removed in 4.0.

Choose a reason for hiding this comment

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

Kernel::getEnvParameters()

which will tell the Kernel to use the response code set on the event's
response object.

* The`getEnvParameters()` method has been removed.

Choose a reason for hiding this comment

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

Kernel::getEnvParameters()

* Deprecated`LazyLoadingFragmentHandler::addRendererService()`
* Added`SessionListener`
* Added`TestSessionListener`
* Deprecated`getEnvParameters`

Choose a reason for hiding this comment

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

Kernel::getEnvParameters()

{
$_SERVER['SYMFONY__REDIS_HOST'] =getenv('REDIS_HOST');
$_SERVER['REDIS_HOST'] =getenv('REDIS_HOST');
}
Copy link
Member

Choose a reason for hiding this comment

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

seems unnecessary

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I wasn't sure. Can I remove both setUp() and tearDown() ?

Copy link
Member

Choose a reason for hiding this comment

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

I would say yes

@fabpot
Copy link
Member

Tests are broken.

Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

👍

@javiereguiluz
Copy link
MemberAuthor

The last failing tests seem unrelated, so this is now ready! A big "thank you" to@chalasr for his great help fixing all the failing tests.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍

@fabpot
Copy link
Member

Thank you@javiereguiluz.

@fabpotfabpot mentioned this pull requestMay 1, 2017
roverwolf added a commit to opensalt/opensalt that referenced this pull requestAug 15, 2017
The special SYMFONY__ environment variables have been deprecated inSymfony 3.3 (and will be removed in 4.0) as there is now support forruntime environment variables in Symfony.This commit allows for different environment variables to be used as thefirst step in removing the old variables.  A later step should removethe `parameters.yml` file entirely and have the configuration be solelyfrom passed environment variables (or .env file for development).ref: [Deprecation blog post](https://symfony.com/blog/new-in-symfony-3-3-deprecated-the-special-symfony-environment-variables)ref:symfony/symfony#21889
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

6 participants

@javiereguiluz@chalasr@robfrawley@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp