PHP 4.0 Bug #8002: PHP caches files opened with file().
| From: | brett_paul at mindspring dot com | Date: | Tue, 28 Nov 2000 06:03:28 +0000 |
| Subject: | PHP 4.0 Bug #8002: PHP caches files opened with file(). | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-39346@lists.php.net to get a copy of this message | ||
From: brett_paul@mindspring.com
Operating system: Windows 95
PHP version: 4.0.3pl1
PHP Bug Type: Directory function related
Bug description: PHP caches files opened with file().
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>
--
Edit Bug report at: http://bugs.php.net/?id=8002&edit=1