-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RTM] Improve zlib stream check #41
Conversation
&& ($reader = new XMLReader) | ||
&& @$reader->open('compress.zlib://data:text/xml,<x/>') === true | ||
&& @$reader->read() === true | ||
&& @$reader->close() === true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it is wrong to test the object instantiation.
if (null === $zlibSupport) {
$zlibSupport = false;
if (\in_array('compress.zlib', stream_get_wrappers(), true)) {
$reader = new XMLReader();
if (true === @$reader->open('compress.zlib://data:text/xml,<x/>')) {
$zlibSupport = true;
}
@$reader->close();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code doesn’t test the read()
method. How about this?
if (null === $zlibSupport) {
$reader = new XMLReader();
$zlibSupport =
\in_array('compress.zlib', stream_get_wrappers(), true)
&& true === @$reader->open('compress.zlib://data:text/xml,<x/>')
&& true === @$reader->read()
;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file is 'compress.zlib://data:text/xml,<x/>'
. How can this be opened but not read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example compress.zlib://data:text/xml,
can be opened but not read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is not our test string, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but if the compress.zlib
wrapper doesn’t work correctly it could currupt the <x/>
and this would result in read()
returning false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very unlikely but then just keep it as it is.
Fixes #38