diff --git a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php new file mode 100644 index 0000000..af75b41 --- /dev/null +++ b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php @@ -0,0 +1,79 @@ +shopwareVersion, '>')) { + return; + } + + $this->checkCompression($collection, 'Cache', $this->cacheCompressionEnabled, $this->cacheCompressionMethod); + $this->checkCompression($collection, 'Cart', $this->cartCompressionEnabled, $this->cartCompressionMethod); + } + + private function checkCompression(HealthCollection $collection, string $functionality, bool $enabled, string $method): void + { + if (!$enabled) { + $collection->add( + SettingsResult::warning( + strtolower($functionality) . '-compress', + $functionality . ' compression', + 'disabled', + 'enabled', + self::DOCUMENTATION_URL, + ), + ); + + return; + } + + if ($method === 'gzip') { + $collection->add( + SettingsResult::warning( + strtolower($functionality) . '-compression-method', + $functionality . ' compression method', + 'gzip', + 'zstd', + self::DOCUMENTATION_URL, + ), + ); + + return; + } + + if ($method === 'zstd' && !extension_loaded('zstd')) { + $collection->add( + SettingsResult::error( + strtolower($functionality) . '-compression-method-extension-zstd', + 'PHP extension zstd for ' . $functionality . ' compression method', + 'disabled', + 'enabled', + self::DOCUMENTATION_URL, + ), + ); + } + } +} diff --git a/src/DependencyInjection/SymfonyConfigCompilerPass.php b/src/DependencyInjection/SymfonyConfigCompilerPass.php index 4b57955..a09df98 100644 --- a/src/DependencyInjection/SymfonyConfigCompilerPass.php +++ b/src/DependencyInjection/SymfonyConfigCompilerPass.php @@ -23,5 +23,13 @@ public function process(ContainerBuilder $container): void } else { $container->setParameter('frosh_tools.queue_connection', 'unknown://default'); } + + if (!$container->hasParameter('shopware.cache.cache_compression_method')) { + $container->setParameter('shopware.cache.cache_compression_method', false); + } + + if (!$container->hasParameter('shopware.cart.compression_method')) { + $container->setParameter('shopware.cart.compression_method', false); + } } }