Skip to content

Commit 39a32be

Browse files
committed
fix: guard factories cache writes
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
1 parent 44aaddb commit 39a32be

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

system/Cache/FactoriesCache/FileVarExportHandler.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ 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);
24+
if (! is_dir($this->path) && ! @mkdir($this->path, 0777, true) && ! is_dir($this->path)) {
25+
return;
2626
}
2727

2828
// Write to temp file first to ensure atomicity
@@ -31,7 +31,9 @@ public function save(string $key, mixed $val): void
3131
return;
3232
}
3333

34-
rename($tmp, $this->path . "/{$key}");
34+
if (! @rename($tmp, $this->path . "/{$key}")) {
35+
@unlink($tmp);
36+
}
3537
}
3638

3739
public function delete(string $key): void

0 commit comments

Comments
 (0)