Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
javiereguiluz commentedMar 6, 2017
| Q | A |
|---|---|
| Branch? | master |
| Bug fix? | no |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | yes |
| Tests pass? | yes |
| Fixed tickets | #20089 |
| License | MIT |
| Doc PR | - |
chalasr commentedMar 6, 2017
I surely miss something but#20100 (comment):
Or do we plan to trigger this deprecation forever? |
robfrawley commentedMar 6, 2017
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 commentedMar 12, 2017
@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 commentedMar 12, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 with |
chalasr commentedMar 14, 2017
@javiereguiluz My point is mainly what@robfrawley said in the previous comment, but also that deprecating |
javiereguiluz commentedMar 14, 2017
@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 commentedMar 14, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
In think this implem here is right, but misses the deprecation of 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; |
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.
%env()% should be%%env()%%
javiereguiluz commentedMar 14, 2017
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 commentedMar 14, 2017
Reopening, this looks like the correct approach to me:
|
chalasr commentedMar 14, 2017
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 commentedMar 14, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@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. |
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.
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
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.
%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); |
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.
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)
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.
or not use it anymore :)
nicolas-grekas commentedMar 14, 2017
missing entries in CHANGELOG / UPGRADE files |
fabpot commentedMar 14, 2017
👍 |
nicolas-grekas left a comment
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.
A few comments, a rebase, and a test fix, then all good on my side.
UPGRADE-3.3.md Outdated
| 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. |
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.
Kernel::getEnvParameters()
UPGRADE-4.0.md Outdated
| which will tell the Kernel to use the response code set on the event's | ||
| response object. | ||
| * The`getEnvParameters()` method has been removed. |
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.
Kernel::getEnvParameters()
| * Deprecated`LazyLoadingFragmentHandler::addRendererService()` | ||
| * Added`SessionListener` | ||
| * Added`TestSessionListener` | ||
| * Deprecated`getEnvParameters` |
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.
Kernel::getEnvParameters()
| { | ||
| $_SERVER['SYMFONY__REDIS_HOST'] =getenv('REDIS_HOST'); | ||
| $_SERVER['REDIS_HOST'] =getenv('REDIS_HOST'); | ||
| } |
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.
seems unnecessary
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.
I wasn't sure. Can I remove both setUp() and tearDown() ?
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.
I would say yes
fabpot commentedMar 20, 2017
Tests are broken. |
chalasr left a comment
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.
👍
javiereguiluz commentedMar 21, 2017
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. |
nicolas-grekas left a comment
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.
👍
fabpot commentedMar 21, 2017
Thank you@javiereguiluz. |
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