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

fix lstat bug cache directory race condition #9253

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
use function fclose;
use function file_exists;
use function file_get_contents;
use function filetype;
use function flock;
use function fopen;
use function get_class;
Expand Down Expand Up @@ -2502,11 +2501,12 @@ public static function removeCacheDirectory(string $dir): void
$full_path = $dir . '/' . $object;

// if it was deleted in the meantime/race condition with other psalm process
clearstatcache(true, $full_path);
if (!file_exists($full_path)) {
continue;
}

if (filetype($full_path) === 'dir') {
if (is_dir($full_path)) {
self::removeCacheDirectory($full_path);
} else {
$fp = fopen($full_path, 'c');
Expand Down