On 21.12.2024 at 06:49, Larry Garfield wrote: > On Fri, Dec 20, 2024, at 3:35 PM, Christoph M. Becker wrote: > >> I still think the stat cache should be *deprecated* first. That gives >> users a chance to reconsider calling multiple stat related functions >> instead of doing a single stat() call. See my previous comment[1] for >> some further details. >> >> [1] <https://github.com/php/php-src/pull/5894#issuecomment-2546473892> > > What exactly would deprecation look like here? My plan was to just rip the > cache out, and update clearstatcache() to be a no-op, but issue a deprecation > message "Hey, this doesn't do anything anymore." And then we can remove the > function itself in like PHP 10 or something, because it doesn't hurt anything > to leave it be. > > I don't see there being much value to a period of "hey, this is *going* to do > nothing in the future", when users couldn't do anything about it. That just > gives them a deprecation notice they cannot fix, if they're in one of the > very few situations where manually clearing the cache is useful. That > doesn't seem great.
I believe the whole point of the stat cache is to optimize multiple consecutive calls to stat releted functions on the same file *name*. E.g. code like $mtime = filemtime($filename); $fsize = filesize($filename); would be a relevant example. Such code could be changed in userland to $stat = stat($filename); $mtime = $stat["mtime"]; $fsize = $stat["stat"]; where the stat cache would be irrelevant. Of course, users who are not aware that there may be a difference in performance won't even think about that. As such a deprecation message could be triggered whenever the stat cache is hit, possibly pointing also to the file:line where the cache had been populated. The usefulness of this is based on the assumption that it's pretty unlikely that the stat cache is hit from unrelated code paths. If a general deprecation is not desired (and that seems to be the case), I'm also fine with a PR/patch that users could apply themselves, similar what Nikita did back then when string to number comparisons changed[1]. Note that clearstatcache() should not be no-opped altogether; clearing (parts of) the realpath cache seems still useful. [1] <https://github.com/php/php-src/pull/3917> Christoph