[php-src] Issue #24256: PHP 8.6.0RC3: fclose returns FALSE instead of TRUE with stream wrappers

From: Date: Sun, 11 Oct 2026 09:05:57 +0000
Subject: [php-src] Issue #24256: PHP 8.6.0RC3: fclose returns FALSE instead of TRUE with stream wrappers
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252970@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/24256 Author: thekid ### Description The following code: ```php <?php class Buffer { public function __construct(public string $bytes= '') { } public function uri(): string { return Buffers::uri($this); } } class Buffers { private static $buffers= []; private $id; public $context; public static function uri(Buffer $buffer): string { static $id= 0; self::$buffers[$id++]= $buffer; return "buffers://{$id}"; } public function stream_open($path, $mode, $options, &$opened) { $this->id= (int)parse_url($path, PHP_URL_PATH); if (!isset(self::$buffers[$this->id])) { throw new Exception("Cannot open buffer {$this->id}"); } $opened= $path; return true; } public function stream_write($bytes) { self::$buffers[$this->id]->bytes.= $bytes; return strlen($bytes); } public function stream_close() { unset(self::$buffers[$this->id]); return true; } } stream_wrapper_register('buffers', Buffers::class); $buffer= new Buffer(); $fd= fopen($buffer->uri(), 'rb'); var_dump(['fd' => $fd]); var_dump(['fwrite' => fwrite($fd, 'Test')]); var_dump(['fclose' => fclose($fd)]); var_dump($buffer); ``` Resulted in this output: ``` array(1) { ["fd"]=> resource(6) of type (stream) } array(1) { ["fwrite"]=> int(4) } array(1) { ["fclose"]=> bool(false) } object(Buffer)#1 (1) { ["bytes"]=> string(4) "Test" } ``` But I expected this output instead: ``` array(1) { ["fd"]=> resource(6) of type (stream) } array(1) { ["fwrite"]=> int(4) } array(1) { ["fclose"]=> bool(true) } object(Buffer)#1 (1) { ["bytes"]=> string(4) "Test" } ``` ...or easier to read as a diff: ```diff --- 8.6-dev 2026-10-11 10:59:36.748154800 +0200 +++ 8.6rc3 2026-10-11 10:59:46.076000800 +0200 @@ -8,7 +8,7 @@ } array(1) { ["fclose"]=> - bool(true) + bool(false) } object(Buffer)#1 (1) { ["bytes"]=> ``` ### PHP Version ```plain PHP 8.6.0RC3 (cli) (built: Oct 6 2026 17:21:26) (NTS Visual C++ 2026 x64) Copyright © The PHP Group and Contributors Built by The PHP Group Zend Engine v4.6.0RC3, Copyright © Zend by Perforce with Zend OPcache v8.6.0RC3, Copyright ©, by Zend by Perforce ``` ### Operating System Windows 11

« previous php.bugs (#252970) next »