1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Merge pull request #8714 from kkmuffme/dont-rewrite-config-hash-to-cache-when-unchanged

Fix cache race condition due to missing repopulation of lock files cache
This commit is contained in:
orklah 2022-11-18 22:08:37 +01:00 committed by GitHub
commit 4e17585093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -369,7 +369,7 @@ class ProjectAnalyzer
}
if ($this->file_reference_provider->cache) {
$this->file_reference_provider->cache->hasConfigChanged();
$this->file_reference_provider->cache->setConfigHashCache();
}
$this->project_cache_provider->updateComposerLockHash();
@ -385,8 +385,10 @@ class ProjectAnalyzer
Config::removeCacheDirectory($cache_directory);
}
$this->file_reference_provider->cache->setConfigHashCache();
if ($this->project_cache_provider) {
$this->project_cache_provider->hasLockfileChanged();
$this->project_cache_provider->updateComposerLockHash();
}
}
}

View File

@ -66,9 +66,7 @@ class FileReferenceCacheProvider
public function hasConfigChanged(): bool
{
$new_hash = $this->config->computeHash();
$has_changed = $new_hash !== $this->getConfigHashCache();
$this->setConfigHashCache($new_hash);
return $has_changed;
return $new_hash !== $this->getConfigHashCache();
}
/**
@ -998,7 +996,7 @@ class FileReferenceCacheProvider
return false;
}
public function setConfigHashCache(string $hash): void
public function setConfigHashCache(string $hash = ''): void
{
$cache_directory = Config::getInstance()->getCacheDirectory();
@ -1006,6 +1004,10 @@ class FileReferenceCacheProvider
return;
}
if ($hash === '') {
$hash = $this->config->computeHash();
}
if (!is_dir($cache_directory)) {
try {
if (mkdir($cache_directory, 0777, true) === false) {