Skip to content

Commit 23e13e2

Browse files
committed
Fix #81475: stream_isatty emits warning with attached stream wrapper
We must not issue warnings, if `show_err` is false. Closes GH-7513.
1 parent 2d66840 commit 23e13e2

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ PHP NEWS
2424
. Fixed bug #80663 (Recursive SplFixedArray::setSize() may cause double-free).
2525
(cmb, Nikita, Tyson Andre)
2626

27+
- Streams:
28+
. Fixed bug #81475 (stream_isatty emits warning with attached stream wrapper).
29+
(cmb)
30+
2731
- XML:
2832
. Fixed bug #70962 (XML_OPTION_SKIP_WHITE strips embedded whitespace).
2933
(Aliaksandr Bystry, cmb)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #81475 (stream_isatty emits warning with attached stream wrapper)
3+
--FILE--
4+
<?php
5+
$stdout = fopen('php://stdout', 'wb');
6+
stream_filter_append($stdout, 'string.toupper');
7+
var_dump(stream_isatty($stdout));
8+
?>
9+
--EXPECT--
10+
bool(false)

main/streams/cast.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
295295
}
296296

297297
if (php_stream_is_filtered(stream)) {
298-
php_error_docref(NULL, E_WARNING, "cannot cast a filtered stream on this system");
298+
if (show_err) {
299+
php_error_docref(NULL, E_WARNING, "cannot cast a filtered stream on this system");
300+
}
299301
return FAILURE;
300302
} else if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS) {
301303
goto exit_success;

0 commit comments

Comments
 (0)