Skip to content

Commit a186c9f

Browse files
bug #47280: [HttpFoundation] prevent incomplete profile dumps
1 parent 79ee32a commit a186c9f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,14 @@ public function write(Profile $profile): bool
168168
];
169169

170170
$context = stream_context_create();
171+
$wrapper = '';
171172

172173
if (\function_exists('gzcompress')) {
173-
$file = 'compress.zlib://'.$file;
174+
$wrapper = 'compress.zlib://';
174175
stream_context_set_option($context, 'zlib', 'level', 3);
175176
}
176177

177-
if (false === file_put_contents($file, serialize($data), 0, $context)) {
178+
if (false === file_put_contents($wrapper.$file.'.tmp', serialize($data), 0, $context) || false === rename($file.'.tmp', $file)) {
178179
return false;
179180
}
180181

0 commit comments

Comments
 (0)