Re: Adding a way to disable the stat cache
| From: | Kevin Lyda | Date: | Fri, 03 Sep 2021 16:15:49 +0000 |
| Subject: | Re: Adding a way to disable the stat cache | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115937@lists.php.net to get a copy of this message | ||
On Fri, Sep 3, 2021 at 4:24 PM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Just to throw it out there: Maybe we should clear the stat cache when functions in the exec
> family are used? Even if we allow disabling the stat cache, I think we can easily avoid that
> particular footgun. And if calls to external binaries are involved we likely don't have to
> worry about stat overhead.
This code also breaks:
<?php
$testfile= 'bug28790.write.out';
function print_stat($filename) {
$s = @stat($filename);
echo "$filename: ".$s['size']."\n";
}
$f = fopen($testfile, "a");
print_stat($testfile);
fwrite($f, "five\n");
print_stat($testfile);
fclose($f);
So you'd need to add fwrite and a number of other functions to the ones managing
this cache. And after all that, external programs (or forked children)
can ruin your
day. One could argue that making a bug more arcane is a form of cruelty.
Kevin