Skip to content

Fix GH-10092 (Internal stream casting should not emit lost bytes warning twice) #10093

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.15


- Core:
. Fixed bug GH-10092 (Internal stream casting should not emit lost bytes
warning twice). (Girgias)

05 Jan 2023, PHP 8.1.14

Expand Down
9 changes: 9 additions & 0 deletions ext/standard/tests/file/gh10092.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--TEST--
Bug GH-10092 (Internal stream casting should not emit lost bytes warning twice)
--FILE--
<?php
$handle = fopen('http://example.com', 'r');
var_dump(stream_isatty($handle));
?>
--EXPECT--
bool(false)
4 changes: 3 additions & 1 deletion main/streams/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show

exit_success:

if ((stream->writepos - stream->readpos) > 0 &&
if (
show_err &&
(stream->writepos - stream->readpos) > 0 &&
stream->fclose_stdiocast != PHP_STREAM_FCLOSE_FOPENCOOKIE &&
(flags & PHP_STREAM_CAST_INTERNAL) == 0
) {
Expand Down