Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Disable fine-grained caching" checker #282

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Frosh\Tools\Components\Health\Checker\PerformanceChecker;

use Frosh\Tools\Components\Health\Checker\CheckerInterface;
use Frosh\Tools\Components\Health\HealthCollection;
use Frosh\Tools\Components\Health\SettingsResult;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

class FineGrainedCachingChecker implements PerformanceCheckerInterface, CheckerInterface
{
public const DOCUMENTATION_URL = 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-fine-grained-caching';

public function __construct(
#[Autowire('%kernel.shopware_version%')]
public readonly string $shopwareVersion,
#[Autowire('%shopware.cache.tagging.each_config%')]
public readonly bool $cacheTaggingEachConfig,
#[Autowire('%shopware.cache.tagging.each_snippet%')]
public readonly bool $cacheTaggingEachSnippet,
#[Autowire('%shopware.cache.tagging.each_theme_config%')]
public readonly bool $cacheTaggingEachThemeConfig,
) {}

public function collect(HealthCollection $collection): void
{
if (\version_compare('6.5.4.0', $this->shopwareVersion, '>')) {
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,
),
);
}
}
}
12 changes: 12 additions & 0 deletions src/DependencyInjection/SymfonyConfigCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ public function process(ContainerBuilder $container): void
if (!$container->hasParameter('shopware.cart.compression_method')) {
$container->setParameter('shopware.cart.compression_method', false);
}

if (!$container->hasParameter('shopware.cache.tagging.each_config')) {
$container->setParameter('shopware.cache.tagging.each_config', true);
}

if (!$container->hasParameter('shopware.cache.tagging.each_snippet')) {
$container->setParameter('shopware.cache.tagging.each_snippet', true);
}

if (!$container->hasParameter('shopware.cache.tagging.each_theme_config')) {
$container->setParameter('shopware.cache.tagging.each_theme_config', true);
}
}
}