Skip to content

Commit 01c0c64

Browse files
committed
Revert "saveCache() is atomic [Closes #11]"
This reverts commit b703b4f.
1 parent 180f89e commit 01c0c64

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/RobotLoader/RobotLoader.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,9 @@ private function loadCache(): void
438438
private function saveCache(): void
439439
{
440440
$file = $this->getCacheFile();
441-
$tempFile = $file . uniqid('', true) . '.tmp';
442441
$code = "<?php\nreturn " . var_export([$this->classes, $this->missing], true) . ";\n";
443-
if (file_put_contents($tempFile, $code) !== strlen($code) || !rename($tempFile, $file)) {
444-
@unlink($tempFile); // @ - file may not exist
442+
if (file_put_contents("$file.tmp", $code) !== strlen($code) || !rename("$file.tmp", $file)) {
443+
@unlink("$file.tmp"); // @ - file may not exist
445444
throw new \RuntimeException("Unable to create '$file'.");
446445
}
447446
if (function_exists('opcache_invalidate')) {

0 commit comments

Comments
 (0)