Doc #60602 [Opn->Csd]: $env can be destructively changed.
Edit report at https://bugs.php.net/bug.php?id=60602&edit=1
ID: 60602
Updated by: datibbaw@php.net
Reported by: me at ktamura dot com
Summary: $env can be destructively changed.
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: OSX 10.6.8
PHP Version: 5.4SVN-2011-12-23 (SVN)
-Assigned To:
+Assigned To: datibbaw
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2013-10-10 04:13:33] 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.
------------------------------------------------------------------------
[2012-02-25 20:36:53] 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
------------------------------------------------------------------------
[2011-12-23 16:48:01] me at ktamura dot com
the "../futz/a.php" in the expected/actual output is the script's name.
------------------------------------------------------------------------
[2011-12-23 16:27:45] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60602&edit=1
Thread (6 messages)