php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69277 PHP-FPM crashes on file_put_contents call
Submitted: 2015-03-22 17:42 UTC Modified: 2015-04-05 04:22 UTC
From: sebastien dot vray at gmail dot com Assigned:
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: Irrelevant OS: Fedora 21 3.18.3-201.fc21.i686
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-03-22 17:42 UTC] sebastien dot vray at gmail dot com
Description:
------------
Let's assume the file foo.txt with read only permissions or 744 chmod and the owner of the PHP-FPM process is not the same as foo.txt, if you try to write something in it with the function file_put_contents you'll get a "503 service unavailable" response from apache plus a ambigous warning in the error log:

22-Mar-2015 17:47:27 Europe/Paris] PHP Warning:  file_put_contents(foo.txt): °¶»áÈ in /var/www/xxx/api/Library/Log.php on line 121

While using respectively fopen(), fwrite(), and fclose() on the same file with the same conditions and appropriate controls will produce nothing.

My PHP version is 5.6.4





Test script:
---------------
<?php

//foo.txt has 444 chmod or PHP-FPM user doesn't have the appropriate write permissions on the file

//This makes PHP-FPM crash
file_put_contents('foo.txt', 'Whatever', FILE_APPEND);//Makes PHP-FPM crash

//While this doesn't
$fpLog = @fopen($path, 'ba+');
if ($fpLog) {
	@fwrite($fp, $content);
	@fclose($fpLog);
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-23 06:57 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2015-03-23 06:57 UTC] laruence@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2015-04-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 15:03:37 2021 UTC