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

From: Date: Fri, 07 Nov 2008 12:15:30 +0000
Subject: #44124 [Opn->Bgs]: 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-1435@lists.php.net to get a copy of this message
ID: 44124 Updated by: vrana@php.net Reported By: jausions@php.net -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: Irrelevant PHP Version: 5.2.5 New Comment: STREAM_REPORT_ERRORS is a Stream's flag (which is clearly stated in the constant description), it has nothing to do with fopen(). Previous Comments: ------------------------------------------------------------------------ [2008-02-15 01:16:31] jausions@php.net Yes, I looked at the documentation, and try to give a chance to passing STREAM_REPORT_ERRORS in the $option of fopen(), as nowhere else I found where to actually enable that feature. I WANT to be able to turn it on, if only to help debugging. I could throw an exception instead, but it is not what the documentation says either, since a mere TRUE / FALSE response is expected from stream_open(). ini_set() doesn't seem to have a stream-related trigger_error setting either. I can take care of the handling part of STREAM_REPORT_ERRORS inside my stream class just fine... but now I can't test it, since I can't seem to force the stream API to actually pass that flag. So, as I said, it might just be a serious lack of documentation, or an actual bug. It's a moot point to ask the stream class to handle trigger_error() when the developer has no mean to test it. ------------------------------------------------------------------------ [2008-02-14 23:27:34] jani@php.net 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.. ------------------------------------------------------------------------ [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 (#1435) next »