Skip to content
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

PHP 8.3.17 - Very strange is_file() issue on CLI #17915

Open
everdio opened this issue Feb 24, 2025 · 1 comment
Open

PHP 8.3.17 - Very strange is_file() issue on CLI #17915

everdio opened this issue Feb 24, 2025 · 1 comment

Comments

@everdio
Copy link

everdio commented Feb 24, 2025

Description

To reproduce this you can create these 3 files:
test1.php

<?php foreach (\array_fill(0, 10, "test") as $key => $content) { \file_put_contents("test_" . $key . ".tmp", $content); }

test2.php
<?php while(true) { foreach (\array_fill(0, 10, "test") as $key => $content) { $file = "test_" . $key . ".tmp"; echo \is_file($file) . " => " . \file_exists($file) . \PHP_EOL; } sleep(2); }

and test3.php
<?php foreach (\array_fill(0, 10, "test") as $key => $content) { \unlink("test_" . $key . ".tmp"); sleep(2); }

First yuu run test1.php, this just creates 10 dummy files. Then start running test2.php and open another terminal. In that second terminal run test3.php which will remove the files 1 by 1.

test2.php will start outputting as expected, until the very last file, it will keep reporting the final is_file as true while the file is really gone ?

PHP Version

PHP 8.3.17

Operating System

Debian GNU/Linux 12 (bookworm)

@cmb69
Copy link
Member

cmb69 commented Feb 24, 2025

Sounds like a realpath cache issue, and wouldn't probably be a bug, since is_file() results are cached, but file_exists() results are not – oh, that might be Windows only (needs F_OK to be defined; not sure about POSIX systems).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants