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: 2020-10-27 13:03 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: cmb (profile)
Status: Closed Package: Streams related
PHP Version: 5.6.4 OS: All
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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
 [2020-10-27 13:03 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2020-10-27 13:03 UTC] cmb@php.net
A bit late to document this, though.
 [2020-10-27 13:12 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=c2fea13ec01631394e1f5cc20aefe2fce1e299fe
Log: Fix #68798: stream_select() preserves keys since rev. 305856 breaking some code without note
 [2020-10-27 13:12 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-10-27 19:30 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=fe657af3f7e647eadaa1bbbe6e85e8abd8075047
Log: Fix #68798: stream_select() preserves keys
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=a089ad6bf8e11cf113f879f1a7bf1fda21c67c93
Log: Fix #68798: stream_select() preserves keys
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC