Skip to content

Handle race condition when creating cache directory #326

Handle race condition when creating cache directory

Handle race condition when creating cache directory #326

Triggered via pull request January 11, 2025 14:55
@vjikvjik
opened #89
mkdir-fix
Status Success
Total duration 46s
Artifacts

mutation.yml

on: pull_request
Matrix: mutation / roave-infection
Fit to window
Zoom out
Zoom in

Annotations

5 warnings
mutation / PHP 8.3-ubuntu-latest
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
mutation / PHP 8.3-ubuntu-latest: src/FileCache.php#L128
Escaped Mutant for Mutator "LogicalAndNegation": --- Original +++ New @@ @@ // If ownership differs, the touch call will fail, so we try to // rebuild the file from scratch by deleting it first // https://github.com/yiisoft/yii2/pull/16120 - if (function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid()) { + if (!(function_exists('posix_geteuid') && is_file($file) && fileowner($file) !== posix_geteuid())) { @Unlink($file); } if (file_put_contents($file, serialize($value), LOCK_EX) === false) {
mutation / PHP 8.3-ubuntu-latest: src/FileCache.php#L189
Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ public function setMultiple(iterable $values, null|int|DateInterval $ttl = null) : bool { $values = $this->iterableToArray($values); - $this->validateKeys(array_map('\\strval', array_keys($values))); + foreach ($values as $key => $value) { $this->set((string) $key, $value, $ttl); }
mutation / PHP 8.3-ubuntu-latest: src/FileCache.php#L207
Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ foreach ($keys as $key) { $this->delete($key); } - return true; + return false; } public function has(string $key) : bool {
mutation / PHP 8.3-ubuntu-latest: src/FileCache.php#L332
Escaped Mutant for Mutator "FunctionCallRemoval": --- Original +++ New @@ @@ if (is_file($path)) { throw new CacheException("Failed to create cache directory, file with the same name exists: \"{$path}\"."); } - set_error_handler(static function (int $errorNumber, string $errorString) use($path) : bool { - if (is_dir($path)) { - return true; - } - throw new CacheException(sprintf('Failed to create directory "%s". %s', $path, $errorString), $errorNumber); - }); + try { mkdir($path, recursive: true); } finally {