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

[Process] Setting empty environment variable no longer work since 4.0.2 #25564

Copy link
Copy link
Closed
@OndraM

Description

@OndraM
Issue body actions
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0.2
<?php // process.php

var_dump(getenv('MY_VARIABLE'));
<?php // runner.php

require_once __DIR__ . '/vendor/autoload.php';

$process = new \Symfony\Component\Process\Process(
    'php process.php',
     __DIR__, 
    ['MY_VARIABLE' => '']
);
$process->run();

echo $process->getOutput();

Symfony 4.0.0, 4.0.1:

$ php runner.php 
string(0) ""

Symfony 4.0.2:

$ php runner.php 
bool(false)

This is probably related to PHP bug https://bugs.php.net/bug.php?id=71868 and was perhaps caused by changes in #25417 & #24924 (cc @nicolas-grekas ).

Symfony until 4.0.1 did not pass the variables to proc_open (which is where the PHP bug comes into an effect).

The workaround in 4.0.2 I found is to pass the variables in a "key=value" format:

Process('php process.php', __DIR__, ['MY_VARIABLE=']);

(though I don't know what could be broken by this...)

In our CLI app we depend on the original behavior (ie. empty value of the variable is what we expect, and has different meaning than "variable not set at all"), and as this is impact of PHP bug, it would be nice if Symfony could still workaround it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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