Req #54004 [Opn->Bgs]: proc_open() should accept php:// wrappers for file
Edit report at http://bugs.php.net/bug.php?id=54004&edit=1
ID: 54004
Updated by: cataphract@php.net
Reported by: asari at users dot sourceforge dot net
Summary: proc_open() should accept php:// wrappers for file
-Status: Open
+Status: Bogus
Type: Feature/Change Request
Package: Unknown/Other Function
Operating System: Linux (Ubuntu x86)
PHP Version: trunk-SVN-2011-02-12 (snap)
Block user comment: N
Private report: N
New Comment:
This cannot be done for php://output and, in most cases (though for the
CLI it could be done), for php://input. The reason is that the output
buffering chain cannot be written to through a simple file descriptor.
Previous Comments:
------------------------------------------------------------------------
[2011-02-13 00:59:03] asari at users dot sourceforge dot net
Description:
------------
---
From manual page: http://www.php.net/function.proc-open
---
proc_open() can attach files for the child process' standard
input/output/error,
but can't attach php:// wrapper. As far as I tried, http:// wrapper
works fine.
If wrappers can be used for proc_open(), in many cases I think we can
avoid
complicated stream_select() programming using non-blocking i/o, as
dk at brightbyte dot de does in
http://www.php.net/function.shell-exec.php
.
Test script:
---------------
<?php
header("Content-Type: application/octet-stream");
proc_close(proc_open("zcat",
array(
0 => array("file", "php://input", "r"),
1 => array("file", "php://output", "w"),
2 => array("file", "/dev/null", "a")
), $pipes));
Expected result:
----------------
Ungzip'ed content should be displayed when HTTP POST with gzip'ed
request body or
when executed in CLI with gzip'ed standard input.
Actual result:
--------------
$ ~/local/php-trunk-20110212/bin/php -v
PHP 5.3.99-dev (cli) (built: Feb 13 2011 08:00:27)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies
$ ~/local/php-trunk-20110212/bin/php zcat.php <
/usr/share/doc/php5/TODO.gz
Warning: proc_open(): cannot represent a stream of type Input as a File
Descriptor in /path/to/zcat.php on line 8
Warning: proc_close() expects parameter 1 to be resource, boolean given
in
/path/to/zcat.php on line 8
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54004&edit=1
Thread (2 messages)