|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79965 Why does the manual say fread/fwrite changed in PHP 7.4?
Submitted: 2020-08-12 17:03 UTC Modified: 2020-08-12 22:28 UTC
From: thiemo dot kreuz at wikimedia dot de Assigned:
Status: Verified Package: *Directory/Filesystem functions
PHP Version: 7.4.9 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: thiemo dot kreuz at wikimedia dot de
New email:
PHP Version: OS:


 [2020-08-12 17:03 UTC] thiemo dot kreuz at wikimedia dot de
From manual page:

Quote: "fread() and fwrite() will now return FALSE if the operation failed. Previously an empty string or 0 was returned."

This is not correct, or at least misleading. Both functions are documented to return false in case of a failure ever since. What changed in PHP 7.4? I tried to find the related code change, but all I found are bugfixes. Does this section refer to a bugfix? Maybe there was a very specific failure situation that was not reported via false?

TL;DR: Please re-write or remove this misleading section from the migration manual.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-12 21:57 UTC]
-Status: Open +Status: Verified
 [2020-08-12 21:57 UTC]
The relevant commit is d59aac5[1]; the PHPTs show that some, but
not all return values in case of failure have been changed from
int(0) to bool(false).

[1] <;a=commit;h=d59aac58b3e7da7ad01a194fe9840d89725ea229>
 [2020-08-12 22:28 UTC] thiemo dot kreuz at wikimedia dot de
Oh wow, that's a massive change. Thanks!

I guess the manual should say something like "fread/fwrite will now return false in all error situations, as it was always documented. Before, an empty string or 0 was returned in many error situations, e.g. when a gzip stream couldn't be decoded, or when writing to a file that was opened in read mode."

Note it's not only fread/fwrite, but also fgetcsv/fputcsv.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Sep 22 05:01:30 2020 UTC