php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71868 Environment variables with no value are filtered out by proc_open()
Submitted: 2016-03-21 14:12 UTC Modified: 2016-03-21 14:13 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: enrico dot stahn at gmail dot com Assigned:
Status: Open Package: Program Execution
PHP Version: 5.6.19 OS: Debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-03-21 14:12 UTC] enrico dot stahn at gmail dot com
Description:
------------
Empty environment variables passed to proc_open are filtered out.

Test script:
---------------
<?php
// process.php

$env = ['FOO' => 'abc', 'BAR' => ''];
$pipes = [];
$process = proc_open('./env.php', [], $pipes, `pwd`, $env);
proc_close($process);


#!/usr/bin/php
<?php
// env.php

var_dump($_SERVER['FOO']);
var_dump($_SERVER['BAR']);
php process.php will output:

string(3) "abc"
PHP Notice:  Undefined index: BAR in /Users/kuba/Projects/symfony/issues/env.php on line 6
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-21 14:13 UTC] enrico dot stahn at gmail dot com
https://github.com/symfony/symfony/issues/18170#issuecomment-199225778
 [2016-04-14 23:01 UTC] chrispmaiden at gmail dot com
I can confirm I'm able to reproduce this behaviour on both 5 and 7 branches. I've been working on a failing test which is at https://github.com/matason/php-src/commit/eab2ae391702f4287fad7c9885d45585d606464f

I'm pretty sure I have a fix for the 5 branch, I will follow up with that and a fix for the 7 branch.

Best,

Chris
 [2016-04-16 12:50 UTC] chrispmaiden at gmail dot com
I've pushed a commit to my fork which appears to fix the issue, https://github.com/matason/php-src/commit/39c546d0499470b5437e3d24d909b63f994558ec

I'd appreciate review from someone who knows the code better than I!
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 18:01:38 2019 UTC