Doc #78375 [Com]: stream_set_option method of stream wrapper is now called inside require()
Edit report at https://bugs.php.net/bug.php?id=78375&edit=1
ID: 78375
Comment by: bkfake-php at yahoo dot com
Reported by: mail at ciaranmcnulty dot com
Summary: stream_set_option method of stream wrapper is now
called inside require()
Status: Verified
Type: Documentation Problem
Package: Streams related
Operating System: Debian Slim (docker)
PHP Version: 7.4.0beta1
Block user comment: N
Private report: N
New Comment:
More documentation issues:
stream_set_option (https://www.php.net/manual/en/streamwrapper.stream-set-option.php)
makes no mention of STREAM_OPTION_READ_BUFFER
stream_set_option documentation doesn't describe what STREAM_BUFFER_NONE and STREAM_BUFFER_FULL
designate / how they should be handled (as the previous comment mentions there is no example
implementation)
stream constants documentation (https://www.php.net/manual/en/stream.constants.php) does not list
any of these constants
STREAM_OPTION_BLOCKING
STREAM_OPTION_READ_TIMEOUT
STREAM_OPTION_READ_BUFFER
STREAM_OPTION_WRITE_BUFFER
STREAM_BUFFER_NONE
STREAM_BUFFER_FULL
In my attempt to find libraries that implement read/write buffer I've found broken
implementations such as
case STREAM_OPTION_WRITE_BUFFER:
return stream_set_write_buffer($this->fp, $arg1);
case STREAM_OPTION_READ_BUFFER:
return stream_set_read_buffer($this->fp, $arg1);
This is broken on multiple levels (passing $arg1 rather than $arg2 / assumes that
stream_set_(read|write)_buffer return boolean [they do not] / otherwise ignoring $arg1's value)
-----
possibly related?:
I'm using a streamWrapper to inject "declare(ticks=1);" on the fly for a
debugger/profiler...
in php 7.4 it appears that require only reads the number of bytes that stream_stat
reports/returns... Even though stream_read is returning the entire buffer... This results in
"PHP Parse error: syntax error, unexpected end of file"
increasing $stats['size'] to account for the injected string length solves this...
Could this be READ_BUFFER NONE/FULL related
Previous Comments:
------------------------------------------------------------------------
[2019-10-01 14:54:14] mail at ciaranmcnulty dot com
Just as a note the example at https://www.php.net/manual/en/stream.streamwrapper.example-1.php
doesn't implement this method
------------------------------------------------------------------------
[2019-08-08 08:20:38] nikic@php.net
Upgrading note added in https://github.com/php/php-src/commit/8a4171ac457c048e1b05b2d9fc9b74f4816272a0.
I considered adding a special hack to hide the warning for this case, but overall I feel it would do
more harm than good. Custom stream wrapper implementations aren't exactly super common, so
I'd err on the side of consistent behavior here.
------------------------------------------------------------------------
[2019-08-06 14:21:03] mail at ciaranmcnulty dot com
This is indeed a docs problem! For some reason I hadnât realised it is just a Warning
------------------------------------------------------------------------
[2019-08-05 17:15:38] cmb@php.net
Well, this is a deliberate BC break caused by an optimization[1],
and as such not a bug. However, this change is not documented in
UPGRADING, and indeed PHP_STREAM_OPTION_READ_BUFFER (the option
with value 2) is missing from the PHP manual.
[1] <http://git.php.net/?p=php-src.git;a=commit;h=a986e70991057785cd3e5f4235215cb933351b4d>
------------------------------------------------------------------------
[2019-08-05 16:00:47] cmb@php.net
Confirmed: <https://3v4l.org/QjgOW>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78375
--
Edit this bug report at https://bugs.php.net/bug.php?id=78375&edit=1
Thread (5 messages)