Doc #79965 [Ver]: Why does the manual say fread/fwrite changed in PHP 7.4?

From: Date: Wed, 12 Aug 2020 22:28:11 +0000
Subject: Doc #79965 [Ver]: Why does the manual say fread/fwrite changed in PHP 7.4?
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17770@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79965&edit=1

 ID:                 79965
 User updated by:    thiemo dot kreuz at wikimedia dot de
 Reported by:        thiemo dot kreuz at wikimedia dot de
 Summary:            Why does the manual say fread/fwrite changed in PHP
                     7.4?
 Status:             Verified
 Type:               Documentation Problem
 Package:            *Directory/Filesystem functions
 PHP Version:        7.4.9
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2020-08-12 21:57:27] cmb@php.net

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] <http://git.php.net/?p=php-src.git;a=commit;h=d59aac58b3e7da7ad01a194fe9840d89725ea229>

------------------------------------------------------------------------
[2020-08-12 17:03:19] thiemo dot kreuz at wikimedia dot de

Description:
------------
---
From manual page: https://php.net/migration74.incompatible
---

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.

https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.core.fread-fwrite



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79965&edit=1


Thread (6 messages)

« previous php.doc.bugs (#17770) next »