php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51109 Filesys functions write duplicate output
Submitted: 2010-02-22 04:59 UTC Modified: 2010-02-22 05:37 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: animatorboy at verizon dot net Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.12 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: animatorboy at verizon dot net
New email:
PHP Version: OS:

 

 [2010-02-22 04:59 UTC] animatorboy at verizon dot net
Description:
------------
When I try to write to a file, whether the file exists or not the text 
sent is written twice.  I tried using a counter to see if it was looping 
somewhere however it proved that the code was only run once.

Reproduce code:
---------------
$msg = 'TEST';
$fp = ('./logs/somefile.php');
file_put_contents($fp,$msg,FILE_APPEND);

or

$msg = 'TEST';
$fp = fopen('./logs/somefile.php','ab');
flock($fp, LOCK_EX);    
fwrite($fp, $msg);
flock($fp, LOCK_UN);
fclose($fp);

Expected result:
----------------
TEST

Actual result:
--------------
TESTEST

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-22 05:21 UTC] rasmus@php.net
Really?  That simple 3-line test write "TEST" twice to the file?  
Forget your other code, just run the simple test.  I certainly can't 
reproduce that here and I am very skeptical that you can reproduce it 
with that code as well.
 [2010-02-22 05:30 UTC] animatorboy at verizon dot net
I could not believe it either, I have pulling my hair out all day!  
Let me try and give a little more information.


This is my server, pretty basic.  
/
/dev
/dev/logs/
/public_html/
/public_html/logs/

I have a live version (/public_html/) and a dev server (/dev/).  On 
the live server the code works great, on the dev server it doesn't.

I sent the code to a friend to see if he could help and his server 
started doing the same thing!

I made a small mistake on the PHP version when I submitted, it's 5.2.6 
not .12 but I don't think that will make a HUGE difference with this 
bug, not that I have any control over it anyway because the host that 
is running my site won't update!

Any ideas?
 [2010-02-22 05:37 UTC] rasmus@php.net
None whatsoever.  We can't fix something we can't see.  And 5.2.6 is 
ancient.  If you can reliably reproduce it in a current version, let us 
know.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 10:01:34 2025 UTC