Bug #64921 [Opn->Nab]: Inconsistent stream_select() behavior for php://memory vs. php://temp

From: Date: Wed, 02 Apr 2014 14:00:11 +0000
Subject: Bug #64921 [Opn->Nab]: Inconsistent stream_select() behavior for php://memory vs. php://temp
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185041@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64921&edit=1 ID: 64921 Updated by: mike@php.net Reported by: rdlowrey at gmail dot com Summary: Inconsistent stream_select() behavior for php://memory vs. php://temp -Status: Open +Status: Not a bug Type: Bug Package: Streams related Operating System: Fedora 17 PHP Version: 5.4.15 Block user comment: N Private report: N New Comment: - select()'ing on a temp stream will convert it to a temp file (descriptor) - regular files are always reported readable - EOF is only detected on read Summing up gives the described behaviour, which seems pretty fine to me. Previous Comments: ------------------------------------------------------------------------ [2013-05-25 17:09:12] rdlowrey at gmail dot com 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#185041) next »