[php-src] Issue #9441: fseek does not work with php://input even though the stream is advertised as streamable

From: Date: Sun, 28 Aug 2022 03:30:02 +0000
Subject: [php-src] Issue #9441: fseek does not work with php://input even though the stream is advertised as streamable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242320@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9441 Author: bohwaz ### Description ```php $a = fopen('php://input', 'r'); var_dump(stream_get_meta_data($a)['seekable']); var_dump(ftell($a)); var_dump(fseek($a, 10, SEEK_SET)); var_dump(ftell($a)); ``` Resulted in this output: ``` bool(true) int(0) int(-1) bool(false) ``` But I expected this output instead: ``` bool(true) int(0) int(0) int(10) ``` If you actually read through to the end of the stream, it becomes seekable: ``` $a = fopen('php://input', 'r'); while (!feof($a)) { fread($a, 8192); } var_dump(stream_get_meta_data($a)['seekable']); var_dump(ftell($a)); var_dump(fseek($a, 10, SEEK_SET)); var_dump(ftell($a)); var_dump(fseek($a, 0, SEEK_END)); var_dump(ftell($a)); ``` Results in what is expected: ``` bool(true) int(30320) int(0) int(10) int(0) int(30320) ``` ### PHP Version PHP/8.1.9 ### Operating System Debian stable

« previous php.bugs (#242320) next »