php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60602 $env can be destructively changed.
Submitted: 2011-12-23 16:27 UTC Modified: 2014-03-02 22:56 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: me at ktamura dot com Assigned: datibbaw (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4SVN-2011-12-23 (SVN) OS: OSX 10.6.8
Private report: No CVE-ID: None
 [2011-12-23 16:27 UTC] me at ktamura dot com
Description:
------------
---
From manual page: http://www.php.net/function.proc-open#refsect1-function.proc-
open-description
---

The $env argument can be destructively changed as a result of calling proc_open. 
We should either document so or change the behavior of the function so that $env's 
values are not changed as a result of invoking proc_open.

Test script:
---------------
<?php
print_r($_SERVER['argv']);
$pipes = array();
proc_open('/bin/echo', array(), $pipes, null, $_SERVER);
print_r($_SERVER['argv']);

Expected result:
----------------
Array
(
    [0] => ../futz/a.php
)


Array
(
    [0] => ../futz/a.php
)

Actual result:
--------------
Array
(
    [0] => ../futz/a.php
)

Array

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-23 16:48 UTC] me at ktamura dot com
the "../futz/a.php" in the expected/actual output is the script's name.
 [2012-02-25 20:36 UTC] virtual dot greg at gmail dot com
This does manifest in PHP 5.3.8 on OS X 10.6.8 as well. A question to the OP: the 
documentation says to pass NULL to use the same environment as the current PHP 
process.

If ['argv'] is a string it is unaffected. Only if the element is an array does 
this modification occur. See my gist https://gist.github.com/1910448
 [2013-10-10 04:13 UTC] datibbaw@php.net
The behaviour is accompanied by a notice as well:

> PHP Notice:  Array to string conversion in file on line number

The notice comes from here: http://lxr.php.net/xref/PHP_5_4/ext/standard/proc_open.c#490

Any element in $_SERVER that's not a string will get converted. This should be reflected in the documentation.
 [2014-03-02 22:56 UTC] datibbaw@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: datibbaw
 [2014-03-02 22:56 UTC] datibbaw@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Fixed in next 5.4, 5.5 or 5.6
 [2014-04-05 23:09 UTC] jimmy_libra_98 at hotmail dot com
kiero q me regale un poco de oro y u poco de comandos con unos heros para aser mas fuereete
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC