php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43519 stream_get_meta_data returns invalid mode
Submitted: 2007-12-06 14:26 UTC Modified: 2007-12-06 17:27 UTC
Votes:6
Avg. Score:4.7 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:0 (0.0%)
From: ross dot lawley at gmail dot com Assigned:
Status: Closed Package: Streams related
PHP Version: 5.2.5 OS:
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: ross dot lawley at gmail dot com
New email:
PHP Version: OS:

 

 [2007-12-06 14:26 UTC] ross dot lawley at gmail dot com
Description:
------------
When an fopen() is done on an HTTP URL with mode "r", the 
stream_get_meta_data() result returns "r+"

Please reopen #43510 and close this bug because:

The mode parameter specifies the type of access you have to the stream!

r > Open for reading only; place the file pointer at the beginning of the file.
r+ > Open for reading and writing; place the file pointer at the beginning of the file.

Its in the documentation the meta information *should* report the mode it was opened with so that you can know what you access is to the stream data, it might be handled elsewhere and not being able to rely on the meta data is a BUG

Reproduce code:
---------------
$f = fopen('http://www.google.com/', 'r');
var_dump(stream_get_meta_data($f['mode']));

Expected result:
----------------
string 'r' (length=1)

Actual result:
--------------
string 'r+' (length=2)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-06 17:10 UTC] dz at bitxtender dot com
As with the other bug report that was closed as bogus, the reproduce 
code of course has to be:

$meta = stream_get_meta_data(fopen('http://www.google.com/', 'r'));
var_dump($meta['mode']);

The simple reason why this must work is because one might want to 
serialize an object with a file pointer, and that can only be done by 
grabbing the meta data on sleep, and restoring the stream on wakeup. But 
fopen() on an HTTP resource with r+ gives a warning that the stream does 
not support writing.
 [2007-12-06 17:27 UTC] helly@php.net
Duplicate, see http://bugs.php.net/43510
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 20:01:29 2024 UTC