[php-src] PR #21853: Fix GH-21742: SplFileObject::fgets() throws at EOF in eof/fgets loop

From: Date: Thu, 23 Apr 2026 15:42:13 +0000
Subject: [php-src] PR #21853: Fix GH-21742: SplFileObject::fgets() throws at EOF in eof/fgets loop
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-35857@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/21853 Author: iliaal Fix in 08dad097025 made spl_filesystem_file_read_ex throw Cannot read from file on NULL-buffer. SplFileObject::fgets() now throws inside the documented while (!$spl->eof()) $spl->fgets(), because eof() returns false until a read attempt returns zero bytes, so the loop always makes one extra fgets call past the final newline. Narrow fgets to silent=true and return empty string when the stream is at EOF; keep the throw for non-EOF read failures so userland wrappers that return NULL without setting EOF still surface the error. next, seek, current, fscanf keep the stricter semantics. Fixes #21742

« previous php.git-pulls (#35857) next »