Bug #60110 [Asn->Csd]: fclose(), file_put_contents(), copy() do not return false properly
| From: | bukka@php.net | Date: | Mon, 05 Oct 2026 10:06:27 +0000 |
| Subject: | Bug #60110 [Asn->Csd]: fclose(), file_put_contents(), copy() do not return false properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-252905@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60110&edit=1
ID: 60110
Updated by: bukka@php.net
Reported by: tom at punkave dot com
Summary: fclose(), file_put_contents(), copy() do not return
false properly
-Status: Assigned
+Status: Closed
Type: Bug
Package: Streams related
Operating System: all
PHP Version: 5.3.8
Assigned To: bukka
Block user comment: N
Private report: N
New Comment:
The PR was merged and will be part of 8.6
Previous Comments:
------------------------------------------------------------------------
[2023-08-29 15:41:24] bukka@php.net
I have been looking into this and implemented initial changes in the linked PR. It needs more
checking as noted in the PR though.
------------------------------------------------------------------------
[2023-08-29 15:40:33] bukka@php.net
The following pull request has been associated:
Patch Name: Fix bug #60110 (fclose(), file_put_contents(), copy() do not return false properly)
On GitHub: https://github.com/php/php-src/pull/12067
Patch: https://github.com/php/php-src/pull/12067.patch
------------------------------------------------------------------------
[2021-08-18 11:10:25] cmb@php.net
Related To: Bug #78077
------------------------------------------------------------------------
[2015-05-19 14:10:16] tim at bishnet dot net
Same issue here using file_put_contents:
82607 open("hello.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
82607 fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
82607 lseek(3, 0, SEEK_CUR) = 0
82607 write(3, "Hello, world", 12) = 12
82607 close(3) = -1 EDQUOT (Disk quota exceeded)
Write succeeds but the close fails. file_put_contents doesn't check the result of the close:
https://github.com/php/php-src/blob/master/ext/standard/file.c#L695
Looks unlikely anybody is going to fix this though, given the age of this bug :-(
------------------------------------------------------------------------
[2013-05-07 20:16:47] scottix at gmail dot com
Still a bug
PHP 5.4.14 (cli) (built: May 5 2013 12:09:08)
I am using gluster to write to a file and then in the middle of the write I
perform a unplug power shutoff. Gluster goes into lock mode which is good, what
it is supposed to do. Although php doesn't seem to do the right thing, I did a
strace of the fclose and you can clearly see a -1 is sent, but php is ignoring
it.
//Gluster shut off and gluster mount log shows volume down
//fwrite here although can succeed since it buffers
write(3, "Some Text 2", 11) = 11
write(1, "int(11)\n", 8int(11)
) = 8
// Performed fflush(), not sure about this one
write(1, "bool(true)\n", 11bool(true)
) = 11
// Performed fclose() here
close(3) = -1 ENOTCONN (Transport endpoint is not
connected)
write(1, "bool(true)\n", 11bool(true)
Please make this higher priority.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=60110
--
Edit this bug report at https://bugs.php.net/bug.php?id=60110&edit=1