Bug #81475 [NEW]: stream_isatty emits warning with attached stream wrapper

From: Date: Fri, 24 Sep 2021 14:38:57 +0000
Subject: Bug #81475 [NEW]: stream_isatty emits warning with attached stream wrapper
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236816@lists.php.net to get a copy of this message
From: neclimdul at gmail dot com Operating system: any PHP version: 8.1.0RC2 Package: Streams related Bug Type: Bug Bug description:stream_isatty emits warning with attached stream wrapper Description: ------------ When testing a stream with stream_isatty, if there is a stream wrapper attached to the stream it will emit an unexpected warning. This is unexpected because we're not _using_ the stream in an invalid way, we're testing so we don't use the stream in an invalid way. Possibly specifically to avoid such an edge case or warning. A real world impact of this is when Drupal wrapped stdout for some test suite interactions and Symfony's deprecation handler tests stdout before writing colors to it. https://github.com/symfony/symfony/pull/43149 This happens because isatty delegates the logic to casting and casting has this edge case where it emits the warning. Test script: --------------- <?php // https://3v4l.org/0EHT4 class strtoupper_filter extends php_user_filter { #[\ReturnTypeWillChange] function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = strtoupper($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } } $stdout = fopen('php://stdout', 'wb'); stream_filter_register('capture', strtoupper_filter::class); stream_filter_append($stdout, 'capture'); var_export(stream_isatty($stdout)); Expected result: ---------------- It would seem the method should just return the false without emitting a warning. Actual result: -------------- Warning: stream_isatty(): Cannot cast a filtered stream on this system in /in/0EHT4 on line 19 Warning: stream_isatty(): Cannot cast a filtered stream on this system in /in/0EHT4 on line 19 false -- Edit bug report at https://bugs.php.net/bug.php?id=81475&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81475&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81475&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81475&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81475&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81475&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81475&r=support Expected behavior: https://bugs.php.net/fix.php?id=81475&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81475&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81475&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81475&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81475&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81475&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81475&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81475&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81475&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81475&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81475&r=mysqlcfg

« previous php.bugs (#236816) next »