diff --git a/NEWS b/NEWS index 35388b768f7f7..7b525d6f9189c 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/ext/standard/tests/file/gh10092.phpt b/ext/standard/tests/file/gh10092.phpt new file mode 100644 index 0000000000000..1cad41d2102aa --- /dev/null +++ b/ext/standard/tests/file/gh10092.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug GH-10092 (Internal stream casting should not emit lost bytes warning twice) +--FILE-- + +--EXPECT-- +bool(false) diff --git a/main/streams/cast.c b/main/streams/cast.c index db0f039eae139..8cc4044c7915e 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -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 ) {