Closed ste93cry closed 6 years ago
TBH I don't even remember why this was deprecated in the first place.
Reference: https://github.com/php-http/message/pull/59/files#diff-02ec021fb5dd74712c844daf4aae85c4R64
I'm pretty sure you already saw this, but just for reference according to the CHANGELOG:
FilteredStream::getWriteFilter We did not implement writing to the streams at all. And if we do, the filter is an internal information and should not be used by consuming code.
Maybe $writeFilterOptions
was deprecated because of that
i guess thats it. can you please do a pull request? i'd prefer && count(...)
over the empty you had just to be more explicit.
and yeah, a base64 filter sure would be cool, please go ahead with a pull request for that (a separate one from the bugfix)
reading mark's comment in slack, i agree we should list which filters to forward [] when we receive null to avoid the user having to explicitly pass [] when using some filters. then at least our interface is consistent.
This is what I found out by doing some tests:
null
as value of $writeFilterOptions
string.strip_tags
) crashes the CLI if they expect an array of options but that array is empty (so the fix proposed by me is not suitable)Indeed we could have a lot of code to handle the different built-in PHP filters and cases that there are, but I was wondering if it's worth. I would like to address this issue before you release 1.6
, so count on me for speed whatever way we're going to pursue
I don't mind putting 1.6 on hold to properly address this issue.
@ste93cry, the problems does not exists in stream-filter 1.4, right?
Ive just made a PR to make sure we are using the latest version.
Unfortunately the issue persist because as you can see below the arguments $readFilterOptions
and $writeFilterOptions
are always passed to the Filter\fun
function and so the check implemented in stream-filter 1.4 to workaround the issue always fails because it expects null
arguments to not be passed
argh. is it enough to filter out null arguments on our side? can you do a pull request for this @ste93cry ?
is it enough to filter out null arguments on our side
From my tests it seems it's enough
can you do a pull request for this
I opened a new PR as I could not reuse my old one due to a force push I made
Actual Behavior
When creating my own custom stream to format data into base64 format (are you interested in merging it into core?) I extended the
FilteredStream
class. The PHP built-inconvert.base64-encode
stream filter seems to not acceptnull
as value of the$readFilterOptions
and$writeFilterOptions
arguments. I had to pass an empty array to work around the following error:This fixes the problem, but I then get a deprecation notice saying this:
Expected Behavior
As it seems that not all filters accept
null
as option of thestream_filter_append
function, the deprecation notice should not be triggered when passing an empty arraySteps to Reproduce
Just create a class that extends the
FilteredStream
class and uses theconvert.base64-encode
stream filter without overriding the constructor. It will throw an exception when using it, and if constructor is overriden to fix the problem a deprecation notice will be triggeredPossible Solutions
The only solution I can think of is to check not only that the
$writeFilterOptions
argument is notnull
but also that it's a non-empty array to trigger the deprecation notice. Something like this: