Skip to content

[Bug] file_exists, is_readable and is_writable do not use stat cache #4572

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

Open
ohyeaah opened this issue Mar 31, 2025 · 1 comment
Open
Labels
bug Documentation contains incorrect information

Comments

@ohyeaah
Copy link

ohyeaah commented Mar 31, 2025

Affected page

https://www.php.net/manual/en/function.file-exists.php
https://www.php.net/manual/en/function.is-readable.php
https://www.php.net/manual/en/function.is-writable.php

Issue description

In the notes section of all three links it says the function is using stat cache but it isn't.
When you run on Linux:

strace php --run "echo is_dir('moh123');" 2>&1 | grep moh123
strace php --run "echo file_exists('moh123');" 2>&1 | grep moh123

You will see that is_dir uses newfstatat syscall which indicates that it's using stat cache.
While file_exists uses access syscall which indicates it's not using stat cache.

Steps to reproduce

  1. Create a file called moh123
  2. Run the test script
<?php
while (true)
{
   echo file_exists("moh123") ? 1 : 0;
   sleep(1);
}
  1. Delete file moh123 and you will see that the output changes (because it's not cached).

Suggested fix

Remove stat cache note.

I'm using Debian and PHP 8.2.28

@ohyeaah ohyeaah added the bug Documentation contains incorrect information label Mar 31, 2025
@ohyeaah
Copy link
Author

ohyeaah commented Apr 1, 2025

Same for is_executable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Documentation contains incorrect information
Projects
None yet
Development

No branches or pull requests

1 participant