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

Appearance settings

[WebServerBundle] fix a bug where require would not require the good file because of env #25523

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

Conversation

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Dec 16, 2017

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

This fixes a bug with putenv that could be not working on certain version of php. (>=7.0.0).

@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch from 05888ce to cdd1c58 Compare December 16, 2017 17:02
@@ -32,6 +32,10 @@

$script = getenv('APP_FRONT_CONTROLLER') ?: 'index.php';

if (false === getenv('APP_FRONT_CONTROLLER')) {
$script = $_ENV['APP_FRONT_CONTROLLER'];
Copy link
Member

Choose a reason for hiding this comment

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

Not good, it should not squash the ternary above (when the env var doesn't exist, the value should remain 'index.php'). No need for calling getenv twice also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch from cdd1c58 to cd1dafa Compare December 16, 2017 18:03
@Simperfit
Copy link
Contributor Author

Status: Needs Review

@@ -33,6 +33,7 @@ public function __construct($documentRoot, $env, $address = null, $router = null
}

putenv('APP_FRONT_CONTROLLER='.$file);
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to just remove putenv here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should keep it because like @ostrolucky said there could be cases where $_ENV could be empty

Copy link
Member

Choose a reason for hiding this comment

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

I also think we should remove the call to putenv (but alongside with -dvariable_order)
and then, symfony/process should be bumped to symfony/process ^3.4.2 in the bundle's composer.json

@ostrolucky
Copy link
Contributor

ostrolucky commented Dec 16, 2017

There should be some investigation regarding general usage of getenv/putenv/$_ENV/$_SERVER in Symfony code. I've seen people on slack too who complained that $_SERVER is not populated with Apache, but $_ENV is.

I have tried it now with apache and neither $_SERVER nor $_ENV is populated, but getenv() is. When env is set via .htaccess, both $_SERVER and getenv is populated, but $_ENV isn't

Then there are concurrency issues with getenv()/putenv() and now this PHP bug(?).

Other than these bugs(?), there are also several other disadvantages for env variables. Old parameters.yml seems sweeter and sweeter to me as time goes on.

@Simperfit
Copy link
Contributor Author

Simperfit commented Dec 17, 2017

Status: Needs Review

$script = getenv('APP_FRONT_CONTROLLER') ?: 'index.php';
$script = getenv('APP_FRONT_CONTROLLER');

if (isset($_ENV['APP_FRONT_CONTROLLER']) && false === $script) {
Copy link
Member

@nicolas-grekas nicolas-grekas Dec 18, 2017

Choose a reason for hiding this comment

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

this doesn't work when "E" is not listed in variables_order, which is the default on Ubuntu
note that this file is used only with php -S so we don't care behavior on Apache
I'd suggest to add -dvariables_order=EGPCS when calling php -S, and then we can get rid of the call to getenv completely

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Dec 18, 2017
@chalasr
Copy link
Member

chalasr commented Dec 18, 2017

Should it target 3.3? This code did not change in 3.4 AFAIK

@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch 2 times, most recently from 2bbab0f to 4fdf6d8 Compare December 19, 2017 07:29
@Simperfit
Copy link
Contributor Author

i'll rebase on 3.3, tell me if it's better to rebase on 3.4.

The things is the bug appear only on 3.4 but hey, it could be on 3.3 too I guess.

@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch from 4fdf6d8 to 7f69bf8 Compare December 19, 2017 07:36
@Simperfit Simperfit changed the base branch from 3.4 to 3.3 December 19, 2017 07:37
@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch from 7f69bf8 to 9352603 Compare December 19, 2017 07:37
@nicolas-grekas
Copy link
Member

@Simperfit you forgot to account for this comment (just replace ^3.4.2 by ^3.3.14 since you rebased on 3.3):

symfony/process should be bumped to symfony/process ^3.4.2 in the bundle's composer.json

@nicolas-grekas nicolas-grekas modified the milestones: 3.4, 3.3 Dec 19, 2017
@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch from 9352603 to 2a878a4 Compare December 19, 2017 13:08
@Simperfit Simperfit force-pushed the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch from 2a878a4 to bfeee1f Compare December 19, 2017 13:09
@Simperfit
Copy link
Contributor Author

done @nicolas-grekas

@nicolas-grekas
Copy link
Member

@Simperfit not quite: ^3.3.14 != ~3.3.14 ;)

@nicolas-grekas
Copy link
Member

Thank you @Simperfit.

@nicolas-grekas nicolas-grekas merged commit bfeee1f into symfony:3.3 Dec 20, 2017
nicolas-grekas added a commit that referenced this pull request Dec 20, 2017
…e the good file because of env (Simperfit)

This PR was merged into the 3.3 branch.

Discussion
----------

[WebServerBundle] fix a bug where require would not require the good file because of env

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #25515
| License       | MIT
| Doc PR        |

This fixes a bug with putenv that could be not working on certain version of php. (>=7.0.0).

Commits
-------

bfeee1f [WebServerBundle] fix a bug where require would not require the good file because of env
@Simperfit Simperfit deleted the bugfix/fix-a-bug-with-web-server-bundle-where-putenv-is-not-working branch December 20, 2017 14:42
@@ -19,7 +19,7 @@
"php": "^5.5.9|>=7.0.8",
"symfony/console": "~3.3",
"symfony/http-kernel": "~3.3",
"symfony/process": "~3.3"
"symfony/process": "~3.3.14"
Copy link
Member

@stof stof Dec 20, 2017

Choose a reason for hiding this comment

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

this now forbids using 3.4, so not good. Should be ~3.3.14 || ^3.4.2

Copy link
Member

Choose a reason for hiding this comment

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

was patched while merged, see 743be09

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.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.