diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index 5797bdc415..c6c23289ab 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -119,6 +119,10 @@ class FileProfilerStorage implements ProfilerStorageInterface return null; } + if (\function_exists('gzcompress')) { + $file = 'compress.zlib://'.$file; + } + return $this->createProfileFromData($token, unserialize(file_get_contents($file))); } @@ -161,7 +165,14 @@ class FileProfilerStorage implements ProfilerStorageInterface 'status_code' => $profile->getStatusCode(), ]; - if (false === file_put_contents($file, serialize($data))) { + $context = stream_context_create(); + + if (\function_exists('gzcompress')) { + $file = 'compress.zlib://'.$file; + stream_context_set_option($context, 'zlib', 'level', 3); + } + + if (false === file_put_contents($file, serialize($data), 0, $context)) { return false; } @@ -282,6 +293,10 @@ class FileProfilerStorage implements ProfilerStorageInterface continue; } + if (\function_exists('gzcompress')) { + $file = 'compress.zlib://'.$file; + } + $profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile)); }