[PHP-BUG] Bug #64803 [NEW]: async stream_socket_client return
From: rdlowrey at gmail dot com Operating system: Fedora 17 PHP version: 5.4.15 Package: Streams related Bug Type: Bug Bug description:async stream_socket_client return Description: Normally when creating a client socket connection asynchronously you have to wait until the socket stream can be selected as writable to determine whether or not the connection succeeded. However, when connecting to a nonexistent server on the loopback address there is no way to differentiate between a failed connection and a successful connection using the STREAM_CLIENT_ASYNC_CONNECT flag. The example code connects to a nonexistent server so it should always fail. PHP reports the connection as having succeeded and it's not until you actually attempt to read or write to the socket stream that you can get an accurate `feof()` return value. Test script: --- https://bugs.php.net/bug.php?id=64803&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64803&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64803&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64803&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64803&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64803&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64803&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64803&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64803&r=oldversion Not developer issue:https://bugs.php.net/fix.php?id=64803&r=support Expected behavior: https://bugs.php.net/fix.php?id=64803&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64803&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64803&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64803&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64803&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64803&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64803&r=isapi Install GNU Sed:https://bugs.php.net/fix.php?id=64803&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64803&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64803&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64803&r=mysqlcfg
[PHP-BUG] Bug #64921 [NEW]: Inconsistent stream_select() behavior for php://memory vs. php://temp
From: rdlowrey at gmail dot com Operating system: Fedora 17 PHP version: 5.4.15 Package: Streams related Bug Type: Bug Bug description:Inconsistent stream_select() behavior for php://memory vs. php://temp 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 bug report at https://bugs.php.net/bug.php?id=64921&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64921&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64921&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64921&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64921&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64921&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64921&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64921&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64921&r=oldversion Not developer issue:https://bugs.php.net/fix.php?id=64921&r=support Expected behavior: https://bugs.php.net/fix.php?id=64921&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64921&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64921&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64921&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64921&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64921&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64921&r=isapi Install GNU Sed:https://bugs.php.net/fix.php?id=64921&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64921&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64921&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64921&r=mysqlcfg
Bug #64921 [Opn]: Inconsistent stream_select() behavior for php://memory vs. php://temp
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