Doc #60602 [Opn]: $env can be destructively changed.
| From: | datibbaw@php.net | Date: | Thu, 10 Oct 2013 04:13:33 +0000 |
| Subject: | Doc #60602 [Opn]: $env can be destructively changed. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10467@lists.php.net to get a copy of this message | ||
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
Type: Documentation Problem
Package: Documentation problem
Operating System: OSX 10.6.8
PHP Version: 5.4SVN-2011-12-23 (SVN)
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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