-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document touch() doesn't clear the stat cache. #4301
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not unique about touch()
. None of the file operations clear the stat cache:
<?php
var_dump(filemtime('/tmp/foo.txt'), filesize('/tmp/foo.txt'));
file_put_contents('/tmp/foo.txt', str_repeat('x', random_int(0, 999)));
clearstatcache();
var_dump(filemtime('/tmp/foo.txt'), filesize('/tmp/foo.txt'));
Seems like we should add the same warning to other functions, then. Is it worth making an entity out of it, or just copy-paste-tweak? |
We already have the |
Co-authored-by: Gina Peter Banyard <[email protected]>
What is insufficient is my awareness that entity already exists. 😄 Switched to using that, and added |
<function>fileperms</function>. | ||
<function>filetype</function>, | ||
<function>fileperms</function>, and. | ||
<function>touch</function>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is wrong. This list lists the functions that read from the stat cache. touch()
is a setter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description says nothing about read/ It just says "Affected."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context is:
When you use stat(), lstat(), or any of the other functions listed in the affected functions list (below), PHP caches the information those functions return in order to provide faster performance.
touch()
is not an affected function, because it does not interact with the stat cache at all. It does not (need to) know about it.
@@ -135,6 +135,16 @@ if (!touch('some_file.txt', $time)) { | |||
<refsect1 role="notes"> | |||
&reftitle.notes; | |||
¬e.filesystem-time-res; | |||
¬e.clearstatcache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And likewise is this change wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then do we need a new entity for statcache impacting write functions? Because the root issue is I didn't realize touch didn't reset the cache, so couldn't understand why my touch() call didn't seem to do anything. So I want something on the touch page to indicate that. You and @Girgias figure out what you want there, I've already made two proposals and both of them someone has objected to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then do we need a new entity for statcache impacting write functions?
None of them impact the statcache (except for unlink()
, which automatically clears it according to the manual). But virtually all of them impact the statdata, because writes implicitly affect the mtime (and usually also the file size).
Note that exec()
and friends might also affect the statdata, because you could exec('touch foo.txt')
. Dom\HTMLDocument::saveHtml()
does as well.
I do not see a value-add in adding a reference to the statcache to every function that possibly affects the statdata and as far as I can tell all the functions reading from the statcache have the note already.
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably list filemtime
first, because the mtime is the relevant field that is modified by touch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
touch can modify both properties, so I listed them in alphabetical order.
Thanks to @derickr for pointing this out to me. It drove me batty for days. 😄