Skip to content

Commit 647bbdb

Browse files
committed
test: fix random-order failures in HotReloader and Autoloader
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
1 parent 7996a81 commit 647bbdb

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

system/Cache/FactoriesCache/FileVarExportHandler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ public function save(string $key, mixed $val): void
2121
{
2222
$val = var_export($val, true);
2323

24+
if (! is_dir($this->path)) {
25+
mkdir($this->path, 0777, true);
26+
}
27+
2428
// Write to temp file first to ensure atomicity
2529
$tmp = $this->path . "/{$key}." . uniqid('', true) . '.tmp';
26-
file_put_contents($tmp, '<?php return ' . $val . ';', LOCK_EX);
30+
if (file_put_contents($tmp, '<?php return ' . $val . ';', LOCK_EX) === false) {
31+
return;
32+
}
2733

2834
rename($tmp, $this->path . "/{$key}");
2935
}

system/HotReloader/DirectoryHasher.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ public function hashDirectory(string $path): string
7373

7474
foreach ($iterator as $file) {
7575
if ($file->isFile()) {
76-
$hashes[] = md5_file($file->getRealPath());
76+
$hashes[$file->getRealPath()] = md5_file($file->getRealPath());
7777
}
7878
}
7979

80+
ksort($hashes);
81+
8082
return md5(implode('', $hashes));
8183
}
8284
}

0 commit comments

Comments
 (0)