php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8002 PHP caches files opened with file().
Submitted: 2000-11-28 01:03 UTC Modified: 2000-11-28 06:51 UTC
From: brett_paul at mindspring dot com Assigned:
Status: Closed Package: Directory function related
PHP Version: 4.0.3pl1 OS: Windows 95
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: brett_paul at mindspring dot com
New email:
PHP Version: OS:

 

 [2000-11-28 01:03 UTC] brett_paul at mindspring dot com
I have a page that I am using to edit files on my site. I read the file using file() and show it in a textarea. I save changes to the file. Upon reloading the page, it does not reflect those changes in the newly presented HTML page (even with a hard refresh), but the underlying file was changed successfully (verified this). Seems to be caching file() reads. A call to clearstatcache() does not clear this. Getting an error seems to clear it, however.

Here's the code. $filename is posted from an HTML form:
<? 
    if (!isset($filename)) {
        $sLocation = dirname($HTTP_REFERER)."index.html";
        header("location:$sLocation");
    }
    $filename = "c:\\xitami\\webpages\\".$filename;
    echo "<HTML>\n<head><title>Edit file $filename </title></head>\n";
    echo "<body bgcolor=\"eadfdf\" basefont size=4>\n";
    
    if (!isset($new)) {
        $new = FALSE;
    }
    
    echo "<form action=\"savefile.php\" method=\"post\">\n";
    if ($new == TRUE) {
        echo "Filename: <input name=\"filename\" length=\"30\"><br>\n";
        $contents = "";
    } else {
        echo "Filename: $filename<input name=\"filename\" type=\"hidden\" value=\"$filename\"><br>\n";
        clearstatcache();
        $contents = file($filename);
        $contents = implode($contents, "");
    }
    
    $contents = stripcslashes($contents);
    echo "<textarea name=\"contents\" cols=75 rows=20 wrap=\"hard\">$contents</textarea>\n";
    
    echo "<input type=\"submit\" value=\"save\">\n";
    echo "</form>\n";
?>
      
</body>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-28 06:51 UTC] stas@php.net
PHP does not cache results of file(), but your browser
probably caches results of your page. Try to disable caching
in your browser.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 12:02:32 2020 UTC