Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d23b74e commit 7331030Copy full SHA for 7331030
src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php
@@ -103,7 +103,10 @@ public function save()
103
104
try {
105
if ($data) {
106
- file_put_contents($this->getFilePath(), serialize($data));
+ $path = $this->getFilePath();
107
+ $tmp = $path.bin2hex(random_bytes(6));
108
+ file_put_contents($tmp, serialize($data));
109
+ rename($tmp, $path);
110
} else {
111
$this->destroy();
112
}
@@ -123,8 +126,11 @@ public function save()
123
126
*/
124
127
private function destroy(): void
125
128
{
- if (is_file($this->getFilePath())) {
129
+ set_error_handler(static function () {});
130
+ try {
131
unlink($this->getFilePath());
132
+ } finally {
133
+ restore_error_handler();
134
135
136
0 commit comments