diff --git a/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php b/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php index a1b43a5f..32647ed3 100644 --- a/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/AdminWorkerChecker.php @@ -19,16 +19,15 @@ public function __construct( public function collect(HealthCollection $collection): void { - if ($this->adminWorkerEnabled) { - $collection->add( - SettingsResult::warning( - 'admin-watcher', - 'Admin-Worker', - 'enabled', - 'disabled', - 'https://developer.shopware.com/docs/guides/plugins/plugins/framework/message-queue/add-message-handler#the-admin-worker', - ), - ); - } + $collection->add( + SettingsResult::create( + $this->adminWorkerEnabled ? 'warning' : 'ok', + 'admin-watcher', + 'Admin-Worker', + $this->adminWorkerEnabled ? 'enabled' : 'disabled', + 'disabled', + 'https://developer.shopware.com/docs/guides/plugins/plugins/framework/message-queue/add-message-handler#the-admin-worker', + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php index b9306913..f91148c9 100644 --- a/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/CompressionMethodChecker.php @@ -41,11 +41,15 @@ private function checkCompression(HealthCollection $collection, string $function return; } + $id = strtolower($functionality) . '-compression-method'; + $snippet = $functionality . ' compression method'; + if ($method === 'gzip') { $collection->add( - SettingsResult::info( - strtolower($functionality) . '-compression-method', - $functionality . ' compression method', + SettingsResult::create( + 'info', + $id, + $snippet, 'gzip', 'zstd', self::DOCUMENTATION_URL, @@ -55,12 +59,15 @@ private function checkCompression(HealthCollection $collection, string $function return; } - if ($method === 'zstd' && !\extension_loaded('zstd')) { + if ($method === 'zstd') { + $extensionLoaded = \extension_loaded('zstd'); + $collection->add( - SettingsResult::error( - strtolower($functionality) . '-compression-method-extension-zstd', - 'PHP extension zstd for ' . $functionality . ' compression method', - 'disabled', + SettingsResult::create( + $extensionLoaded ? 'ok' : 'error', + $id . '-extension-zstd', + 'PHP extension zstd for ' . $snippet, + $extensionLoaded ? 'enabled' : 'disabled', 'enabled', self::DOCUMENTATION_URL, ), diff --git a/src/Components/Health/Checker/PerformanceChecker/DisableAppUrlExternalCheckChecker.php b/src/Components/Health/Checker/PerformanceChecker/DisableAppUrlExternalCheckChecker.php index a91cfa95..080de28a 100644 --- a/src/Components/Health/Checker/PerformanceChecker/DisableAppUrlExternalCheckChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/DisableAppUrlExternalCheckChecker.php @@ -14,16 +14,15 @@ class DisableAppUrlExternalCheckChecker implements PerformanceCheckerInterface, public function collect(HealthCollection $collection): void { $appUrlCheckDisabled = (bool) EnvironmentHelper::getVariable('APP_URL_CHECK_DISABLED', false); - if (!$appUrlCheckDisabled) { - $collection->add( - SettingsResult::warning( - 'app-url-check-disabled', - 'App URL external check', - 'enabled', - 'disabled', - 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-app-url-external-check', - ), - ); - } + $collection->add( + SettingsResult::create( + !$appUrlCheckDisabled ? 'warning' : 'ok', + 'app-url-check-disabled', + 'App URL external check', + !$appUrlCheckDisabled ? 'enabled' : 'disabled', + 'disabled', + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-app-url-external-check', + ) + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php b/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php index 422c03fe..ea5c51ed 100644 --- a/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/DisableSymfonySecretsChecker.php @@ -20,16 +20,15 @@ public function __construct( public function collect(HealthCollection $collection): void { - if ($this->vault) { - $collection->add( - SettingsResult::info( - 'symfony-secrets', - 'Disable Symfony Secrets', - 'enabled', - 'disabled', - 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-symfony-secrets', - ), - ); - } + $collection->add( + SettingsResult::create( + $this->vault ? 'info' : 'ok', + 'symfony-secrets', + 'Disable Symfony Secrets', + $this->vault ? 'enabled' : 'disabled', + 'disabled', + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-symfony-secrets', + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php b/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php index a6f86ce0..c3db3b6f 100644 --- a/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/DisabledMailUpdatesChecker.php @@ -23,13 +23,15 @@ public function collect(HealthCollection $collection): void $setting = $this->params->get('shopware.mail.update_mail_variables_on_send'); - if (!$setting) { - return; - } - - $result = SettingsResult::warning('mail_variables', 'MailVariables updates', 'enabled', 'disabled'); - - $result->url = 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#prevent-mail-data-updates'; - $collection->add($result); + $collection->add( + SettingsResult::create( + !$setting ? 'ok' : 'warning', + 'mail_variables', + 'MailVariables updates', + $setting ? 'enabled' : 'disabled', + 'disabled', + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#prevent-mail-data-updates' + ) + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/EsChecker.php b/src/Components/Health/Checker/PerformanceChecker/EsChecker.php index f40963e6..6d241e39 100644 --- a/src/Components/Health/Checker/PerformanceChecker/EsChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/EsChecker.php @@ -20,16 +20,15 @@ public function __construct(ElasticsearchManager $elasticsearchManager) public function collect(HealthCollection $collection): void { - if (!$this->esEnabled) { - $collection->add( - SettingsResult::info( - 'elasticsearch', - 'Elasticsearch', - 'disabled', - 'enabled', - 'https://developer.shopware.com/docs/guides/hosting/infrastructure/elasticsearch/elasticsearch-setup', - ), - ); - } + $collection->add( + SettingsResult::create( + !$this->esEnabled ? 'info' : 'ok', + 'elasticsearch', + 'Elasticsearch', + !$this->esEnabled ? 'disabled' : 'enabled', + 'enabled', + 'https://developer.shopware.com/docs/guides/hosting/infrastructure/elasticsearch/elasticsearch-setup', + ) + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php b/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php index a7346efc..b052002f 100644 --- a/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/FineGrainedCachingChecker.php @@ -33,18 +33,16 @@ public function collect(HealthCollection $collection): void if (\version_compare($this->shopwareVersion, '6.7.0.0', '>=')) { return; } - - if ($this->cacheTaggingEachConfig || $this->cacheTaggingEachSnippet || $this->cacheTaggingEachThemeConfig) { - $collection->add( - // only info, because it only affects redis, varnish etc. - SettingsResult::info( - 'fine-grained-caching', - 'Fine-grained caching on Redis, Varnish etc.', - 'enabled', - 'disabled', - self::DOCUMENTATION_URL, - ), - ); - } + $collection->add( + // only info, because it only affects redis, varnish etc. + SettingsResult::create( + $this->cacheTaggingEachConfig || $this->cacheTaggingEachSnippet || $this->cacheTaggingEachThemeConfig ? 'info' : 'ok', + 'fine-grained-caching', + 'Fine-grained caching on Redis, Varnish etc.', + 'enabled', + 'disabled', + self::DOCUMENTATION_URL, + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php b/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php index ff881c47..51c4671c 100644 --- a/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/FixCacheIdSetChecker.php @@ -30,16 +30,15 @@ public function collect(HealthCollection $collection): void $cacheId = (string) EnvironmentHelper::getVariable('SHOPWARE_CACHE_ID', ''); - if ($cacheId === '') { - $collection->add( - SettingsResult::warning( - 'cache-id', - 'Fixed cache id', - 'not set', - 'set', - 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#cache-id', - ), - ); - } + $collection->add( + SettingsResult::create( + $cacheId ? 'warning' : 'ok', + 'cache-id', + 'Fixed cache id', + 'not set', + 'set', + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#cache-id', + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php b/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php index 7895e94b..a4662a2c 100644 --- a/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/IncrementStorageChecker.php @@ -23,16 +23,15 @@ public function collect(HealthCollection $collection): void { $recommended = 'array or redis'; - if ($this->userActivity === 'mysql' || $this->queueActivity === 'mysql') { - $collection->add( - SettingsResult::warning( - 'increment-storage', - 'Increment storage', - 'mysql', - $recommended, - 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#increment-storage', - ), - ); - } + $collection->add( + SettingsResult::create( + $this->userActivity === 'mysql' || $this->queueActivity === 'mysql' ? 'warning' : 'ok', + 'increment-storage', + 'Increment storage', + $this->userActivity === 'mysql' || $this->queueActivity === 'mysql' ? 'mysql' : 'array or redis', + $recommended, + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#increment-storage', + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/LoggerLevelChecker.php b/src/Components/Health/Checker/PerformanceChecker/LoggerLevelChecker.php index d531e463..15e6c03a 100644 --- a/src/Components/Health/Checker/PerformanceChecker/LoggerLevelChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/LoggerLevelChecker.php @@ -27,14 +27,15 @@ public function __construct( public function collect(HealthCollection $collection): void { - if ($this->businessEventHandlerLevel->isLowerThan(Level::Warning)) { - $collection->add(SettingsResult::warning( + $collection->add( + SettingsResult::create( + $this->businessEventHandlerLevel->isLowerThan(Level::Warning) ? 'warning' : 'ok', 'business_logger', 'BusinessEventHandler logging', Logger::toMonologLevel($this->businessEventHandlerLevel)->getName(), 'min WARNING', $this->url, - )); - } + ) + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php b/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php index 54801d2d..c3684b83 100644 --- a/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php @@ -19,16 +19,15 @@ public function __construct( public function collect(HealthCollection $collection): void { - if (!$this->mailerIsOverQueue) { - $collection->add( - SettingsResult::warning( - 'mail', - 'Sending mails over queue', - 'disabled', - 'enabled', - 'https://developer.shopware.com/docs/guides/hosting/infrastructure/message-queue#sending-mails-over-the-message-queue', - ), - ); - } + $collection->add( + SettingsResult::create( + !$this->mailerIsOverQueue ? 'warning' : 'ok', + 'mail', + 'Sending mails over queue', + $this->mailerIsOverQueue ? 'enabled' : 'disabled', + 'enabled', + 'https://developer.shopware.com/docs/guides/hosting/infrastructure/message-queue#sending-mails-over-the-message-queue', + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/MessengerAutoSetupChecker.php b/src/Components/Health/Checker/PerformanceChecker/MessengerAutoSetupChecker.php index 406a36ca..2b2da909 100644 --- a/src/Components/Health/Checker/PerformanceChecker/MessengerAutoSetupChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/MessengerAutoSetupChecker.php @@ -23,17 +23,18 @@ public function __construct( public function collect(HealthCollection $collection): void { - if ($this->isAutoSetupEnabled($this->messageTransportDsn) || $this->isAutoSetupEnabled($this->messageTransportDsnLowPriority) || $this->isAutoSetupEnabled($this->messageTransportDsnFailure)) { - $collection->add( - SettingsResult::info( - 'messenger-auto-setup', - 'Messenger auto_setup', - 'enabled', - 'disabled', - 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-auto-setup', - ), - ); - } + $autoSetupState = $this->isAutoSetupEnabled($this->messageTransportDsn) || $this->isAutoSetupEnabled($this->messageTransportDsnLowPriority) || $this->isAutoSetupEnabled($this->messageTransportDsnFailure); + + $collection->add( + SettingsResult::create( + $autoSetupState ? 'info' : 'ok', + 'messenger-auto-setup', + 'Messenger auto_setup', + 'enabled', + 'disabled', + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-auto-setup', + ), + ); } private function isAutoSetupEnabled(string $messageTransportDsn): bool diff --git a/src/Components/Health/Checker/PerformanceChecker/MysqlSettingsChecker.php b/src/Components/Health/Checker/PerformanceChecker/MysqlSettingsChecker.php index 0462f2db..41543aea 100644 --- a/src/Components/Health/Checker/PerformanceChecker/MysqlSettingsChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/MysqlSettingsChecker.php @@ -43,49 +43,50 @@ private function checkGroupConcatMaxLen(HealthCollection $collection): void { /** @var string|false $groupConcatMaxLen */ $groupConcatMaxLen = $this->connection->fetchOne('SELECT @@group_concat_max_len'); - if (!$groupConcatMaxLen || (int) $groupConcatMaxLen < self::MYSQL_GROUP_CONCAT_MAX_LEN) { - $collection->add( - SettingsResult::error( - 'sql_group_concat_max_len', - 'MySQL value group_concat_max_len', - (string) $groupConcatMaxLen, - 'min ' . self::MYSQL_GROUP_CONCAT_MAX_LEN, - self::DOCUMENTATION_URL, - ), - ); - } + $maxLenNotOk = (int) $groupConcatMaxLen < self::MYSQL_GROUP_CONCAT_MAX_LEN; + + $collection->add( + SettingsResult::create( + $maxLenNotOk ? 'warning' : 'ok', + 'sql_group_concat_max_len', + 'MySQL value group_concat_max_len', + (string) $groupConcatMaxLen, + 'min ' . self::MYSQL_GROUP_CONCAT_MAX_LEN, + self::DOCUMENTATION_URL, + ), + ); } private function checkSqlMode(HealthCollection $collection): void { $sqlMode = $this->connection->fetchOne('SELECT @@sql_mode'); - if (\is_string($sqlMode) && \str_contains($sqlMode, self::MYSQL_SQL_MODE_PART)) { - $collection->add( - SettingsResult::error( - 'sql_mode', - 'MySQL value sql_mode', - $sqlMode, - 'No ' . self::MYSQL_SQL_MODE_PART, - self::DOCUMENTATION_URL, - ), - ); - } + $hasForbiddenMode = \is_string($sqlMode) && \str_contains($sqlMode, self::MYSQL_SQL_MODE_PART); + $collection->add( + SettingsResult::create( + $hasForbiddenMode ? 'error' : 'ok', + 'sql_mode', + 'MySQL value sql_mode', + $sqlMode, + 'No ' . self::MYSQL_SQL_MODE_PART, + self::DOCUMENTATION_URL, + ), + ); } private function checkTimeZone(HealthCollection $collection): void { $timeZone = $this->connection->fetchOne('SELECT @@time_zone'); - if (\is_string($timeZone) && !\in_array($timeZone, self::MYSQL_TIME_ZONES, true)) { - $collection->add( - SettingsResult::warning( - 'sql_time_zone', - 'MySQL value time_zone', - $timeZone, - implode(', ', self::MYSQL_TIME_ZONES), - self::DOCUMENTATION_URL, - ), - ); - } + $isInvalidTimeZone = \is_string($timeZone) && !\in_array($timeZone, self::MYSQL_TIME_ZONES, true); + $collection->add( + SettingsResult::create( + $isInvalidTimeZone ? 'warning' : 'ok', + 'sql_time_zone', + 'MySQL value time_zone', + $timeZone, + implode(', ', self::MYSQL_TIME_ZONES), + self::DOCUMENTATION_URL, + ), + ); } private function checkCheckDefaultEnvironmentSessionVariables(HealthCollection $collection): void @@ -96,16 +97,16 @@ private function checkCheckDefaultEnvironmentSessionVariables(HealthCollection $ } $setSessionVariables = (bool) EnvironmentHelper::getVariable('SQL_SET_DEFAULT_SESSION_VARIABLES', true); - if ($setSessionVariables) { - $collection->add( - SettingsResult::warning( - 'sql_set_default_session_variables', - 'MySQL session vars are set on each connect', - 'enabled', - 'disabled', - self::DOCUMENTATION_URL, - ), - ); - } + + $collection->add( + SettingsResult::create( + $setSessionVariables ? 'warning' : 'ok', + 'sql_set_default_session_variables', + 'MySQL session vars are set on each connect', + 'enabled', + 'disabled', + self::DOCUMENTATION_URL, + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/PhpSettingsChecker.php b/src/Components/Health/Checker/PerformanceChecker/PhpSettingsChecker.php index 7c477ffc..2abed748 100644 --- a/src/Components/Health/Checker/PerformanceChecker/PhpSettingsChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/PhpSettingsChecker.php @@ -23,81 +23,80 @@ public function collect(HealthCollection $collection): void private function checkAssertActive(HealthCollection $collection, string $url): void { $currentValue = $this->iniGetFailover('zend.assertions'); - if ($currentValue !== '-1') { - $collection->add( - SettingsResult::warning( - 'zend.assertions', - 'PHP value zend.assertions', - $currentValue, - '-1', - $url, - ), - ); - } + $collection->add( + SettingsResult::create( + $currentValue !== '-1' ? 'warning' : 'ok', + 'zend.assertions', + 'PHP value zend.assertions', + $currentValue, + '-1', + $url, + ), + ); } private function checkEnableFileOverride(HealthCollection $collection, string $url): void { $currentValue = $this->iniGetFailover('opcache.enable_file_override'); - if (!\filter_var($currentValue, \FILTER_VALIDATE_BOOL)) { - $collection->add( - SettingsResult::warning( - 'php.opcache.enable_file_override', - 'PHP value opcache.enable_file_override', - $currentValue, - '1', - $url, - ), - ); - } + $iniFailOver = !\filter_var($currentValue, \FILTER_VALIDATE_BOOL); + $collection->add( + SettingsResult::create( + $iniFailOver ? 'warning' : 'ok', + 'php.opcache.enable_file_override', + 'PHP value opcache.enable_file_override', + $currentValue, + '1', + $url, + ), + ); } private function checkInternedStringsBuffer(HealthCollection $collection, string $url): void { $currentValue = $this->iniGetFailover('opcache.interned_strings_buffer'); - if ((int) $currentValue < 20) { - $collection->add( - SettingsResult::warning( - 'php.opcache.interned_strings_buffer', - 'PHP value opcache.interned_strings_buffer', - $currentValue, - 'min 20', - $url, - ), - ); - } + $buffer = (int) $currentValue < 20; + $collection->add( + SettingsResult::create( + $buffer < 20 ? 'warning' : 'ok', + 'php.opcache.interned_strings_buffer', + 'PHP value opcache.interned_strings_buffer', + $currentValue, + 'min 20', + $url, + ), + ); } private function checkZendDetectUnicode(HealthCollection $collection, string $url): void { $currentValue = $this->iniGetFailover('zend.detect_unicode'); - if (\filter_var($currentValue, \FILTER_VALIDATE_BOOL)) { - $collection->add( - SettingsResult::warning( - 'php.zend.detect_unicode', - 'PHP value zend.detect_unicode', - $currentValue, - '0', - $url, - ), - ); - } + $iniFailOver = \filter_var($currentValue, \FILTER_VALIDATE_BOOL); + $collection->add( + SettingsResult::create( + $iniFailOver ? 'warning' : 'ok', + 'php.zend.detect_unicode', + 'PHP value zend.detect_unicode', + $currentValue, + '0', + $url, + ), + ); } private function checkRealpathCacheTtl(HealthCollection $collection, string $url): void { $currentValue = $this->iniGetFailover('realpath_cache_ttl'); - if ((int) $currentValue < 3600) { - $collection->add( - SettingsResult::warning( - 'php.zend.realpath_cache_ttl', - 'PHP value realpath_cache_ttl', - $currentValue, - 'min 3600', - $url, - ), - ); - } + $ttl = (int) $currentValue < 3600; + $collection->add( + SettingsResult::create( + $ttl < 3600 ? 'warning' : 'ok', + 'php.zend.realpath_cache_ttl', + 'PHP value realpath_cache_ttl', + $currentValue, + 'min 3600', + $url, + ), + ); } private function iniGetFailover(string $option): string diff --git a/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php b/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php index 71115317..1fcdefd0 100644 --- a/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/ProductStreamIndexingChecker.php @@ -26,16 +26,15 @@ public function collect(HealthCollection $collection): void return; } - if ($this->productStreamIndexingEnabled) { - $collection->add( - SettingsResult::info( - 'product-stream-indexing', - 'Product Stream Indexing', - 'enabled', - 'disabled', - 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-product-stream-indexer', - ), - ); - } + $collection->add( + SettingsResult::create( + $this->productStreamIndexingEnabled ? 'info' : 'ok', + 'product-stream-indexing', + 'Product Stream Indexing', + 'enabled', + 'disabled', + 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-product-stream-indexer', + ), + ); } } diff --git a/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php b/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php index 241d07cf..3dbd418e 100644 --- a/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/QueueConnectionChecker.php @@ -11,6 +11,10 @@ class QueueConnectionChecker implements PerformanceCheckerInterface, CheckerInterface { + private const ID = 'queue.adapter'; + private const URL = 'https://developer.shopware.com/docs/guides/hosting/infrastructure/message-queue.html#message-queue-on-production-systems'; + private const RECOMMENDED = 'redis or rabbitmq'; + public function __construct( #[Autowire(param: 'frosh_tools.queue_connection')] protected string $connection, @@ -20,35 +24,38 @@ public function __construct( public function collect(HealthCollection $collection): void { $schema = $this->getSchema(); + $state = $this->determineState($schema); + $snippet = $this->getSnippet($schema); - $id = 'queue.adapter'; - $url = 'https://developer.shopware.com/docs/guides/hosting/infrastructure/message-queue.html#message-queue-on-production-systems'; - - if ($schema === 'doctrine') { - $collection->add( - SettingsResult::warning( - $id, - 'The queue storage in database does not scale well with multiple workers', - $schema, - 'redis or rabbitmq', - $url, - ), - ); + $collection->add( + SettingsResult::create( + $state, + self::ID, + $snippet, + $schema, + self::RECOMMENDED, + self::URL, + ), + ); + } - return; - } + private function determineState(string $schema): string + { + return match ($schema) { + 'redis', 'rabbitmq' => 'ok', + 'doctrine', 'sync' => 'warning', + default => 'info', + }; + } - if ($schema === 'sync') { - $collection->add( - SettingsResult::warning( - $id, - 'The sync queue is not suitable for production environments', - $schema, - 'redis or rabbitmq', - $url, - ), - ); - } + private function getSnippet(string $schema): string + { + return match ($schema) { + 'doctrine' => 'The queue storage in database does not scale well with multiple workers', + 'sync' => 'The sync queue is not suitable for production environments', + 'redis', 'rabbitmq' => '', + default => 'Unknown queue adapter', + }; } private function getSchema(): string diff --git a/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php b/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php index 53208b94..9f55fb6e 100644 --- a/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php +++ b/src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php @@ -21,13 +21,15 @@ public function collect(HealthCollection $collection): void { $httpCacheType = $this->cacheRegistry->get('cache.http')->getType(); - if (!\str_starts_with($httpCacheType, CacheAdapter::TYPE_REDIS) - || \str_starts_with($httpCacheType, CacheAdapter::TYPE_REDIS_TAG_AWARE)) { + // no redis + if (!\str_starts_with($httpCacheType, CacheAdapter::TYPE_REDIS)) { return; } + $notTagAware = !\str_starts_with($httpCacheType, CacheAdapter::TYPE_REDIS_TAG_AWARE); $collection->add( - SettingsResult::warning( + SettingsResult::create( + $notTagAware ? 'warning' : 'ok', 'redis-tag-aware', 'Redis adapter should be TagAware', CacheAdapter::TYPE_REDIS, diff --git a/src/Components/Health/SettingsResult.php b/src/Components/Health/SettingsResult.php index e246e287..0701de29 100644 --- a/src/Components/Health/SettingsResult.php +++ b/src/Components/Health/SettingsResult.php @@ -76,4 +76,21 @@ public static function info(string $id, string $snippet, string $current = '', s return $me; } + + public static function create( + ?string $state, + string $id, + string $snippet, + string $current = '', + string $recommended = '', + ?string $url = null + ): self { + return match ($state) { + 'ok' => self::ok($id, $snippet, $current, $recommended, $url), + 'warning' => self::warning($id, $snippet, $current, $recommended, $url), + 'error' => self::error($id, $snippet, $current, $recommended, $url), + 'info' => self::info($id, $snippet, $current, $recommended, $url), + default => throw new \InvalidArgumentException("Invalid state: {$state}"), + }; + } } diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/template.twig b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/template.twig index 5c58f07a..697bacf2 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/template.twig +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-cache/template.twig @@ -99,4 +99,4 @@ {{ $t('frosh-tools.clearOpCache') }} - + \ No newline at end of file diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js index 607f9664..806e1ea1 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/index.js @@ -10,8 +10,9 @@ Component.register('frosh-tools-tab-index', { data() { return { isLoading: true, + showDone: false, health: null, - performanceStatus: null, + performanceStatus: [], }; }, @@ -39,6 +40,15 @@ Component.register('frosh-tools-tab-index', { }, ]; }, + filteredPerformanceStatus() { + if (this.showDone) { + return this.performanceStatus; + } + + return this.performanceStatus.filter( + (item) => item.state != 'STATE_OK' + ); + }, }, methods: { diff --git a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/template.twig b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/template.twig index acc365e4..83ea253b 100644 --- a/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/template.twig +++ b/src/Resources/app/administration/src/module/frosh-tools/component/frosh-tools-tab-index/template.twig @@ -82,6 +82,14 @@ positionIdentifier="frosh-tools-tab-index-performance" deprecated > + + + + + + + {{ $t('frosh-tools.done') }} +