php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68798 stream_select() preserves keys since rev. 305856 breaking some code without note
Submitted: 2015-01-11 03:14 UTC Modified: 2017-01-28 12:51 UTC
Votes:3
Avg. Score:3.7 ± 1.9
Reproduced:2 of 2 (100.0%)
Same Version:3 (150.0%)
Same OS:1 (50.0%)
From: grzegorz129 at gmail dot com Assigned:
Status: Open Package: Streams related
PHP Version: 5.6.4 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-01-11 03:14 UTC] grzegorz129 at gmail dot com
Description:
------------
Bug #53427 proposed stream_select() should preserve array keys, it was implemented in revision #305856 (http://svn.php.net/viewvc/?view=revision&revision=305856).
However there's no documentation or changelog informations about changed behaviour.
I believe it was first available since 5.4.

Test script:
---------------
$read = $except = null;
$write = ["test" => fopen("php://stdout", "w")];

var_dump($write);
stream_select($read, $write, $except, 0);
var_dump($write);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-11 07:03 UTC] grzegorz129 at gmail dot com
-Summary: stream_select() preserves keys since rev. 305856 +Summary: stream_select() preserves keys since rev. 305856 breaking some code without note
 [2015-01-11 07:03 UTC] grzegorz129 at gmail dot com
I have confirmed stream_select() behave differently on 5.3.29 (tested on OS X).

/******** TEST CODE ********/
$read = $except = null;
$write = array("test" => fopen("php://stdout", "w"));

var_dump($write);
stream_select($read, $write, $except, 0);
var_dump($write);

/******** PHP 5.6.4 ********/
array(1) {
  ["test"]=>
  resource(5) of type (stream)
}
array(1) {
  ["test"]=>
  resource(5) of type (stream)
}

/******** PHP 5.3.29 ********/
array(1) {
  ["test"]=>
  resource(5) of type (stream)
}
array(1) {
  [0]=>
  resource(5) of type (stream)
}


Example of code which conforms to documentation of stream_select() but fails on 5.6.4:

$read = $except = null;
$write = array("test" => fopen("php://stdout", "w"));

stream_select($read, $write, $except, 0);
for($i = 0; $i < count($write); $i++) {
 var_dump($write[$i]); //"resource(n) of type (stream)" on 5.3.29, NULL on 5.6.4
}
 [2017-01-28 12:51 UTC] cmb@php.net
-Package: Documentation problem +Package: Streams related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 19:01:24 2019 UTC