#44124 [Opn]: Options passed to stream_open doesn't match STREAM_REPORT_ERRORS

From: Date: Thu, 14 Feb 2008 23:27:34 +0000
Subject: #44124 [Opn]: Options passed to stream_open doesn't match STREAM_REPORT_ERRORS
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-519@lists.php.net to get a copy of this message
ID: 44124 Updated by: jani@php.net Reported By: jausions@php.net Status: Open -Bug Type: Streams related +Bug Type: Documentation problem Operating System: Irrelevant PHP Version: 5.2.5 New Comment: Perhaps you should first read the manual page for fopen where it clearly says what parameters are expected and where: resource fopen ( string $filename , string $mode [, bool $use_include_path [, resource $context ]] ) 3rd parameter isn't any "options" parameter at all. And second but most important: You're actually not supposed to pass that anywhere, just check for in your wrapper's stream_open() method. Quick search found a pretty good example how it really is supposed to be used: http://pear.php.net/package/OLE/docs/latest/__filesource/fsource_OLE__OLE-0.6.1ChainedBlockStream.php.html Reclassified as documentation issue. The streams implementation sucks and the documentation for it sucks even more.. Previous Comments: ------------------------------------------------------------------------ [2008-02-14 23:11:08] jausions@php.net Update: When passing 0 to the fopen() as option, 4 is received. ------------------------------------------------------------------------ [2008-02-14 23:08:57] jausions@php.net Description: ------------ The $options in stream_open() do not match in any way (or at least in any documented way) with the options passed to fopen() BTW: the documentation of fopen() and stream_open() doesn't make any mention of how the options are passed. So either a bug, or a major lack of documentation, either way, STREAM_REPORT_ERRORS cannot be checked for with the information available on the php.net site. Tested on: 5.1.4, 5.2.0, 5.2.3 and 5.2.5 on different Windows and Debian. Reproduce code: --------------- <?php class StreamTest { public function stream_open($path, $mode, $flags, &$opened_path) { echo 'Received: '.decbin($flags)."\r\n"; return false; } } stream_wrapper_register('test', 'StreamTest'); $flags = array(STREAM_USE_PATH, STREAM_REPORT_ERRORS); echo 'PHP v'.phpversion()."\r\n"; foreach ($flags as $flag) { echo 'Passed: '.decbin($flag)."\r\n"; $fp = @fopen('test://foo', 'r', $flag); } ?> Expected result: ---------------- PHP v5.1.4 Passed: 1 Received: 1 Passed: 1000 Received: 1000 Passed: 0 Received: 0 (or at least a OR on the STREAM_* constant and $flags in stream_open would return TRUE) Actual result: -------------- PHP v5.1.4 Passed: 1 Received: 101 Passed: 1000 Received: 101 Passed: 0 Received: 100 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44124&edit=1

« previous php.doc.bugs (#519) next »