php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22708 writting output to filesystem doesn't work
Submitted: 2003-03-14 13:14 UTC Modified: 2003-03-19 16:52 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: ron dot petty at unigeek dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 4.3.1 OS: Redhat 8
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ron dot petty at unigeek dot com
New email:
PHP Version: OS:

 

 [2003-03-14 13:14 UTC] ron dot petty at unigeek dot com
This is on the command line, not through a browser.

I have wrote some code that reads a file in, modifies it then writes it out to disk.  Then the script reads it back in, however the size is 0.  If I look at the file on the filesystem it is not zero and is correct.  I have tried flush, but that seems to only apply to web based stuff.  I am running this on the command line.  I do fclose the file from the previous write.  I know a work around is to not write anything to the file until its done but this should still work.

1)open file
2)change contents
3)save file
4)open file
file size is incorrect 0, filesystem says it is >0 and correct.

I have the script, but don't know where to upload it?

Thank you.
Ron

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-14 14:13 UTC] ron dot petty at unigeek dot com
I removed the code that reopened the file and did the following instead

...
fclose($h6);

print filesize("/etc/group.backup")."\n";
        print shell_exec("cat /etc/group.backup");
print filesize("/etc/group.backup")."\n";

my output is
0
repett0:x:1102:
drechsel:x:1103:
dan:x:1104:
coty:x:1105:
demo:x:1106:
0

I assume fclose means the file is closed and the output is flushed, but it is not in this case (unless I am not seeing something).
 [2003-03-14 14:48 UTC] ron dot petty at unigeek dot com
I added rewind after reopening and that seemed to work.  I sorta read something in the documentation about how you order opening of files, is there something more in depth?  I still assume this is a bug since I closed them, but rewinding seems to fix it.
 [2003-03-15 06:56 UTC] wez@php.net
PHP caches stat() information (such as that obtained from filesize(), filemtime() etc.) for performance reasons.

Adding a call to clearstatcache() after your fclose() will probably cure your problem.
 [2003-03-19 16:52 UTC] sniper@php.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 "Open". Thank you.


 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC