Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d7d19c

Browse files
[HttpFoundation] use atomic writes in MockFileSessionStorage
1 parent d23b74e commit 0d7d19c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ public function save()
103103

104104
try {
105105
if ($data) {
106-
file_put_contents($this->getFilePath(), serialize($data));
106+
$path = $this->getFilePath();
107+
$tmp = $path.bin2hex(random_bytes(6));
108+
file_put_contents($tmp, serialize($data));
109+
rename($tmp, $path);
107110
} else {
108111
$this->destroy();
109112
}

0 commit comments

Comments
 (0)