Edit report at https://bugs.php.net/bug.php?id=64921&edit=1
ID: 64921
User updated by: rdlowrey at gmail dot com
Reported by: rdlowrey at gmail dot com
Summary: Inconsistent stream_select() behavior for
php://memory vs. php://temp
Status: Open
Type: Bug
Package: Streams related
Operating System: Fedora 17
PHP Version: 5.4.15
Block user comment: N
Private report: N
New Comment:
UPDATE:
According to http://php.net/manual/en/wrappers.php.php php://temp DOES support
stream_select(). However, if this is the case, the behavior described here is
still incorrect because stream_select() reports that the descriptor is readable
even though it has no readable data and feof($stream) === FALSE.
Previous Comments:
------------------------------------------------------------------------
[2013-05-25 00:11:00] rdlowrey at gmail dot com
Description:
------------
Streams of type php://memory cannot be represented as selectable descriptors
where stream_select() is concerned. Attempting to do so will (rightly) trigger
an
E_WARNING along the lines of "Warning: stream_select(): cannot represent a
stream
of type MEMORY as a select()able descriptor in ..."
I would expect streams of type php://temp to behave the same way. However, this
is not the case. Instead, php://temp streams are immediately readable (but do
not
evaluate to TRUE for feof($stream). These streams should either (1) trigger an
error similar to that of php://memory or (2) not be represented as readable by
stream_select().
Test script:
---------------
$stream = fopen('php://memory', 'r+');
$r = array($stream);
$w = $e = NULL;
stream_select($r, $w, $e, 0); // E_WARNING (as expected)
$stream = fopen('php://temp', 'r');
$r = array($stream);
$w = $e = NULL;
if (stream_select($r, $w, $e, 0)) {
var_dump(feof($stream)); // this isn't readable and should never be called
but it results in bool(false)
}
Expected result:
----------------
The test script should trigger two warnings and neither stream should report as
readable.
Actual result:
--------------
php://temp streams do not trigger an error when used with stream_select() and
are
immediately reported as readable.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64921&edit=1