Skip to content

[Process] Inherit env vars by default in PhpProcess #16288

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
Oct 23, 2015

Conversation

nicolas-grekas
Copy link
Member

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

This is the cause of our failures on Windows, where the SYSTEMROOT env var is mandatory for mcrypt_create_iv to work.
I don't know why the browserkit client is run with no env inheritance and this looks like a bug.
Same for PhpProcess emptying the env by default, this looks like a bug, esp. since the parent Process class defaults to inheriting the env.
Tests are not broken by this change.

@@ -851,7 +851,7 @@ public function setEnv(array $env)

$this->env = array();
foreach ($env as $key => $value) {
$this->env[(binary) $key] = (binary) $value;
$this->env[$key] = (string) $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.

this is strictly equivalent

@@ -283,7 +283,7 @@ private static function getClassHierarchy(\ReflectionClass $class)

$traits = array();

if (function_exists('get_declared_traits')) {
if (method_exists('ReflectionClass', 'getTraits')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

not related but still worth cleaning: get_declared_traits is not used after this check; ReflectionClass::getTraits is.

@nicolas-grekas
Copy link
Member Author

See paragonie/random_compat#68 and https://bugs.php.net/70742 for reasons why this is important.

@paragonie-scott
Copy link

@stof
Copy link
Member

stof commented Oct 19, 2015

@paragonie-scott this is a version issue for the inter-package dependencies

@nicolas-grekas nicolas-grekas force-pushed the env-php branch 3 times, most recently from 495f77a to 0852e66 Compare October 20, 2015 07:43
@@ -20,7 +20,7 @@
"symfony/dom-crawler": "~2.0,>=2.0.5"
},
"require-dev": {
"symfony/process": "~2.0,>=2.0.5",
"symfony/process": "~2.3.34|~2.7,>=2.7.6",
Copy link
Member

Choose a reason for hiding this comment

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

We should really start to use the caret operator.

Copy link
Member Author

Choose a reason for hiding this comment

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

someone should open a PR :)

@@ -334,8 +334,7 @@ public function request($method, $uri, array $parameters = array(), array $files
*/
protected function doRequestInProcess($request)
{
// We set the TMPDIR (for Macs) and TEMP (for Windows), because on these platforms the temp directory changes based on the user.
$process = new PhpProcess($this->getScript($request), null, array('TMPDIR' => sys_get_temp_dir(), 'TEMP' => sys_get_temp_dir()));
$process = new PhpProcess($this->getScript($request), null, null);
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to keep the TMPDIR/TEMPDIR? We need to see when and why it was added, but I suppose it was there for a reason.

Copy link
Member

Choose a reason for hiding this comment

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

@fabpot I guess it is because the environment was not inherited by default, and so we forced inheriting part of it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this seemed to be the reason (see 1cec45c and #1785).

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, this was just a workaround against a bug fixed a few lines below (PhpProcess defaulting to not inheriting the env)

@nicolas-grekas nicolas-grekas changed the title [Process] Inherit env vars by default [Process] Inherit env vars by default in PhpProcess Oct 20, 2015
@xabbuh
Copy link
Member

xabbuh commented Oct 23, 2015

👍

@xabbuh
Copy link
Member

xabbuh commented Oct 23, 2015

Status: Reviewed

@Tobion
Copy link
Contributor

Tobion commented Oct 23, 2015

👍

@Tobion
Copy link
Contributor

Tobion commented Oct 23, 2015

Thank you @nicolas-grekas.

@Tobion Tobion merged commit ab8cc29 into symfony:2.3 Oct 23, 2015
Tobion added a commit that referenced this pull request Oct 23, 2015
…as-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[Process] Inherit env vars by default in PhpProcess

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

This is the cause of our failures on Windows, where the SYSTEMROOT env var is mandatory for mcrypt_create_iv to work.
I don't know why the browserkit client is run with no env inheritance and this looks like a bug.
Same for PhpProcess emptying the env by default, this looks like a bug, esp. since the parent `Process` class defaults to inheriting the env.
Tests are not broken by this change.

Commits
-------

ab8cc29 [Process] Inherit env vars by default in PhpProcess
@nicolas-grekas nicolas-grekas deleted the env-php branch October 23, 2015 12:30
This was referenced Oct 27, 2015
@fabpot fabpot mentioned this pull request Oct 27, 2015
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