From 90da8563046b2c11ea85a8a3f70cbc1decd2a338 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:32:27 +0100 Subject: [PATCH 01/14] [Composer] Dropped ci-scripts from dev requirements --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 891bc0e..8f8c0aa 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ "toflar/psr6-symfony-http-cache-store": "^2.2 || ^3.0" }, "require-dev": { - "ibexa/ci-scripts": "^0.2@dev", "ibexa/code-style": "~2.0.0", "ibexa/doctrine-schema": "~5.0.x-dev", "matthiasnoback/symfony-dependency-injection-test": "^4.3", From 9ab54a98ed9752ccf83a148b2166dca479b050b8 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:40:29 +0100 Subject: [PATCH 02/14] [TMP] Required Symfony 6 dev branches of Ibexa packages --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 8f8c0aa..577b4ac 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ "php": " >=8.3", "friendsofsymfony/http-cache": "^2.9", "friendsofsymfony/http-cache-bundle": "^2.8", - "ibexa/core": "~5.0.x-dev", - "ibexa/rest": "~5.0.x-dev", + "ibexa/core": "dev-ibx-8470-symfony-6 as 5.0.x-dev", + "ibexa/rest": "dev-ibx-8470-symfony-6 as 5.0.x-dev", "php-http/curl-client": "^2.1", "psr/http-client": "^1.0", "symfony/config": "^5.0", @@ -31,7 +31,7 @@ }, "require-dev": { "ibexa/code-style": "~2.0.0", - "ibexa/doctrine-schema": "~5.0.x-dev", + "ibexa/doctrine-schema": "dev-ibx-8470-symfony-6 as 5.0.x-dev", "matthiasnoback/symfony-dependency-injection-test": "^4.3", "phpspec/phpspec": "^7.1", "phpunit/phpunit": "^9.6", From 89510209359998bae40ef84935543cf30674bff2 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:40:30 +0100 Subject: [PATCH 03/14] [Composer] Bumped Symfony packages requirements to ^6.4 --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 577b4ac..e82edde 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,13 @@ "ibexa/rest": "dev-ibx-8470-symfony-6 as 5.0.x-dev", "php-http/curl-client": "^2.1", "psr/http-client": "^1.0", - "symfony/config": "^5.0", - "symfony/dependency-injection": "^5.0", - "symfony/event-dispatcher": "^5.0", - "symfony/http-foundation": "^5.0", - "symfony/http-kernel": "^5.0", - "symfony/routing": "^5.0", - "symfony/yaml": "^5.0", + "symfony/config": "^6.4", + "symfony/dependency-injection": "^6.4", + "symfony/event-dispatcher": "^6.4", + "symfony/http-foundation": "^6.4", + "symfony/http-kernel": "^6.4", + "symfony/routing": "^6.4", + "symfony/yaml": "^6.4", "toflar/psr6-symfony-http-cache-store": "^2.2 || ^3.0" }, "require-dev": { @@ -35,7 +35,7 @@ "matthiasnoback/symfony-dependency-injection-test": "^4.3", "phpspec/phpspec": "^7.1", "phpunit/phpunit": "^9.6", - "symfony/phpunit-bridge": "^5.1" + "symfony/phpunit-bridge": "^6.4" }, "autoload": { "psr-4": { From 03a0158a5b17e300b933a28568de3a8d577a4ea6 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:43:39 +0100 Subject: [PATCH 04/14] [Composer] Bumped 3rd party packages to Symfony 6 compatible version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e82edde..8cf9224 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "symfony/http-kernel": "^6.4", "symfony/routing": "^6.4", "symfony/yaml": "^6.4", - "toflar/psr6-symfony-http-cache-store": "^2.2 || ^3.0" + "toflar/psr6-symfony-http-cache-store": "^4.2" }, "require-dev": { "ibexa/code-style": "~2.0.0", From 82e8174de1e8d23477c4cc658e41de21946d967a Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:58:10 +0100 Subject: [PATCH 05/14] Aligned Symfony Bundle extension points code with Symfony 6 --- src/bundle/DependencyInjection/Compiler/DriverPass.php | 2 +- src/bundle/DependencyInjection/Compiler/KernelPass.php | 2 +- .../DependencyInjection/Compiler/ResponseTaggersPass.php | 2 +- src/bundle/DependencyInjection/Compiler/VarnishCachePass.php | 2 +- src/bundle/IbexaHttpCacheBundle.php | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bundle/DependencyInjection/Compiler/DriverPass.php b/src/bundle/DependencyInjection/Compiler/DriverPass.php index 7f94090..3e962a9 100644 --- a/src/bundle/DependencyInjection/Compiler/DriverPass.php +++ b/src/bundle/DependencyInjection/Compiler/DriverPass.php @@ -18,7 +18,7 @@ */ class DriverPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $container->removeAlias('ezpublish.http_cache.purge_client'); diff --git a/src/bundle/DependencyInjection/Compiler/KernelPass.php b/src/bundle/DependencyInjection/Compiler/KernelPass.php index 9653d93..fd027de 100644 --- a/src/bundle/DependencyInjection/Compiler/KernelPass.php +++ b/src/bundle/DependencyInjection/Compiler/KernelPass.php @@ -17,7 +17,7 @@ */ class KernelPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { foreach ($container->getDefinitions() as $id => $definition) { if ($this->isSmartCacheListener($id) || diff --git a/src/bundle/DependencyInjection/Compiler/ResponseTaggersPass.php b/src/bundle/DependencyInjection/Compiler/ResponseTaggersPass.php index 3f2dc3f..c85e8a3 100644 --- a/src/bundle/DependencyInjection/Compiler/ResponseTaggersPass.php +++ b/src/bundle/DependencyInjection/Compiler/ResponseTaggersPass.php @@ -17,7 +17,7 @@ */ class ResponseTaggersPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition(DispatcherTagger::class)) { return; diff --git a/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php b/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php index 10d2be3..b1c916f 100644 --- a/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php +++ b/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php @@ -13,7 +13,7 @@ class VarnishCachePass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $this->processVarnishProxyClientSettings($container); } diff --git a/src/bundle/IbexaHttpCacheBundle.php b/src/bundle/IbexaHttpCacheBundle.php index cf16f3e..d406ca4 100644 --- a/src/bundle/IbexaHttpCacheBundle.php +++ b/src/bundle/IbexaHttpCacheBundle.php @@ -19,7 +19,7 @@ class IbexaHttpCacheBundle extends Bundle { - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); @@ -31,7 +31,7 @@ public function build(ContainerBuilder $container) $this->registerConfigParser($container); } - public function getContainerExtensionClass() + public function getContainerExtensionClass(): string { return IbexaHttpCacheExtension::class; } From c313acdcc58b876207b5b2bd768c8f31718b1648 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:58:37 +0100 Subject: [PATCH 06/14] Aligned Symfony HttpCache extension point code with Symfony 6 --- src/bundle/AppCache.php | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/bundle/AppCache.php b/src/bundle/AppCache.php index d63eca4..69724b9 100644 --- a/src/bundle/AppCache.php +++ b/src/bundle/AppCache.php @@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpCache\StoreInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelInterface; use Toflar\Psr6HttpCacheStore\Psr6Store; @@ -39,15 +40,12 @@ public function __construct(KernelInterface $kernel, $cacheDir = null) $this->addSubscriber(new PurgeListener(['client_ips' => $this->getInternalAllowedIPs()])); } - public function fetch(Request $request, $catch = false) + public function fetch(Request $request, $catch = false): Response { return parent::fetch($request, $catch); } - /** - * {@inheritdoc} - */ - protected function createStore() + protected function createStore(): StoreInterface { return new Psr6Store([ 'cache_tags_header' => TagHeaderFormatter::DEFAULT_HEADER_NAME, @@ -55,10 +53,7 @@ protected function createStore() ]); } - /** - * {@inheritdoc} - */ - public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true) + public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): Response { $response = $this->baseHandle($request, $type, $catch); @@ -72,19 +67,14 @@ public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUE /** * Returns an array of allowed IPs for Http PURGE requests. * - * @return array + * @return string[] */ - protected function getInternalAllowedIPs() + protected function getInternalAllowedIPs(): array { return ['127.0.0.1', '::1']; } - /** - * Perform cleanup of reponse. - * - * @param \Symfony\Component\HttpFoundation\Response $response - */ - protected function cleanupHeadersForProd(Response $response) + protected function cleanupHeadersForProd(Response $response): void { // remove headers that identify the content or internal digest info $response->headers->remove(TagHeaderFormatter::DEFAULT_HEADER_NAME); From f67565af3d6045e2a5d1eece825189d1e02092ca Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:59:11 +0100 Subject: [PATCH 07/14] Aligned Twig extension points code with Symfony 6 --- src/lib/Twig/ContentTaggingExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Twig/ContentTaggingExtension.php b/src/lib/Twig/ContentTaggingExtension.php index b21bc1b..3d1804e 100644 --- a/src/lib/Twig/ContentTaggingExtension.php +++ b/src/lib/Twig/ContentTaggingExtension.php @@ -32,9 +32,9 @@ public function __construct(ResponseTagger $responseTagger, ContentTagInterface } /** - * @return array|\Twig\TwigFunction[] + * @return \Twig\TwigFunction[] */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction( From 51f23f7e110a1e9e855aff431bc94587746c6e23 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 15:59:58 +0100 Subject: [PATCH 08/14] Fixed DI prepend configuration --- src/bundle/DependencyInjection/IbexaHttpCacheExtension.php | 4 ++-- src/bundle/Resources/config/{ => prepend}/fos_http_cache.yml | 0 .../Resources/config/prepend/{ezpublish.yml => ibexa.yml} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/bundle/Resources/config/{ => prepend}/fos_http_cache.yml (100%) rename src/bundle/Resources/config/prepend/{ezpublish.yml => ibexa.yml} (100%) diff --git a/src/bundle/DependencyInjection/IbexaHttpCacheExtension.php b/src/bundle/DependencyInjection/IbexaHttpCacheExtension.php index 7b4daed..5a7beb1 100644 --- a/src/bundle/DependencyInjection/IbexaHttpCacheExtension.php +++ b/src/bundle/DependencyInjection/IbexaHttpCacheExtension.php @@ -56,13 +56,13 @@ public function prepend(ContainerBuilder $container) $loader->load('default_settings.yml'); // Override default settings for FOSHttpCacheBundle - $configFile = __DIR__ . '/../Resources/config/fos_http_cache.yml'; + $configFile = __DIR__ . '/../Resources/config/prepend/fos_http_cache.yml'; $config = Yaml::parse(file_get_contents($configFile)); $container->prependExtensionConfig('fos_http_cache', $config); $container->addResource(new FileResource($configFile)); // Override Core views - $coreExtensionConfigFile = realpath(__DIR__ . '/../Resources/config/prepend/ezpublish.yml'); + $coreExtensionConfigFile = dirname(__DIR__) . '/Resources/config/prepend/ibexa.yml'; $container->prependExtensionConfig('ibexa', Yaml::parseFile($coreExtensionConfigFile)); $container->addResource(new FileResource($coreExtensionConfigFile)); } diff --git a/src/bundle/Resources/config/fos_http_cache.yml b/src/bundle/Resources/config/prepend/fos_http_cache.yml similarity index 100% rename from src/bundle/Resources/config/fos_http_cache.yml rename to src/bundle/Resources/config/prepend/fos_http_cache.yml diff --git a/src/bundle/Resources/config/prepend/ezpublish.yml b/src/bundle/Resources/config/prepend/ibexa.yml similarity index 100% rename from src/bundle/Resources/config/prepend/ezpublish.yml rename to src/bundle/Resources/config/prepend/ibexa.yml From 9bd40dcbb5589393163c3eda8ea2d69320534369 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 20 Nov 2024 16:01:06 +0100 Subject: [PATCH 09/14] Improved codebase quality --- .../Compiler/DriverPass.php | 11 +++----- .../Compiler/KernelPass.php | 28 ++++--------------- .../Compiler/VarnishCachePass.php | 2 +- src/bundle/IbexaHttpCacheBundle.php | 2 +- src/lib/RepositoryTagPrefix.php | 15 +++------- src/lib/Twig/ContentTaggingExtension.php | 12 ++++---- 6 files changed, 20 insertions(+), 50 deletions(-) diff --git a/src/bundle/DependencyInjection/Compiler/DriverPass.php b/src/bundle/DependencyInjection/Compiler/DriverPass.php index 3e962a9..96f3cae 100644 --- a/src/bundle/DependencyInjection/Compiler/DriverPass.php +++ b/src/bundle/DependencyInjection/Compiler/DriverPass.php @@ -42,7 +42,7 @@ public function process(ContainerBuilder $container): void $container->setAlias(ContentTagInterface::class, 'fos_http_cache.http.symfony_response_tagger'); } - public static function getTaggedService(ContainerBuilder $container, $tag) + public static function getTaggedService(ContainerBuilder $container, $tag): string|null { $purgeType = $container->getParameter('ibexa.http_cache.purge_type'); $configuredTagHandlerServiceId = null; @@ -50,16 +50,13 @@ public static function getTaggedService(ContainerBuilder $container, $tag) $tagHandlerServiceIds = $container->findTaggedServiceIds($tag); foreach ($tagHandlerServiceIds as $tagHandlerServiceId => $attributes) { $currentPurgeTypeId = null; - $currentTagHandlerServiceId = null; foreach ($attributes as $attribute) { if (\array_key_exists('purge_type', $attribute)) { $currentPurgeTypeId = $attribute['purge_type']; } - if ($currentPurgeTypeId !== null) { - if ($purgeType === $attribute['purge_type']) { - $configuredTagHandlerServiceId = $tagHandlerServiceId; - break 2; - } + if (($currentPurgeTypeId !== null) && $purgeType === $attribute['purge_type']) { + $configuredTagHandlerServiceId = $tagHandlerServiceId; + break 2; } } if ($currentPurgeTypeId === null) { diff --git a/src/bundle/DependencyInjection/Compiler/KernelPass.php b/src/bundle/DependencyInjection/Compiler/KernelPass.php index fd027de..f719fa9 100644 --- a/src/bundle/DependencyInjection/Compiler/KernelPass.php +++ b/src/bundle/DependencyInjection/Compiler/KernelPass.php @@ -38,10 +38,7 @@ public function process(ContainerBuilder $container): void $container->setParameter('ibexa.http_cache.purge_type', $container->getParameter('ibexa.http_cache.purge_type')); } - /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - */ - protected function removeKernelRoleIdContextProvider(ContainerBuilder $container) + protected function removeKernelRoleIdContextProvider(ContainerBuilder $container): void { if (!$container->hasDefinition('ezpublish.user.identity_definer.role_id')) { return; @@ -63,33 +60,18 @@ protected function removeKernelRoleIdContextProvider(ContainerBuilder $container $container->getDefinition('fos_http_cache.user_context.hash_generator')->setArguments($arguments); } - /** - * @param string $id - * - * @return bool - */ - protected function isSmartCacheListener($id) + protected function isSmartCacheListener(string $id): bool { return preg_match('/^ezpublish\.cache_clear\.content.[a-z_]+_listener/', $id); } - /** - * @param string $id - * - * @return bool - */ - protected function isResponseCacheListener($id) + protected function isResponseCacheListener(string $id): bool { return $id === 'ezpublish.view.cache_response_listener'; } - /** - * @param string $id - * - * @return bool - */ - protected function isCachePurger($id) + protected function isCachePurger(string $id): bool { - return strpos($id, 'ezpublish.http_cache.purger.') === 0; + return str_starts_with($id, 'ezpublish.http_cache.purger.'); } } diff --git a/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php b/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php index b1c916f..1614307 100644 --- a/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php +++ b/src/bundle/DependencyInjection/Compiler/VarnishCachePass.php @@ -18,7 +18,7 @@ public function process(ContainerBuilder $container): void $this->processVarnishProxyClientSettings($container); } - private function processVarnishProxyClientSettings(ContainerBuilder $container) + private function processVarnishProxyClientSettings(ContainerBuilder $container): void { if (!$container->hasDefinition('fos_http_cache.proxy_client.varnish')) { throw new InvalidArgumentException('Varnish proxy client must be enabled in FOSHttpCacheBundle'); diff --git a/src/bundle/IbexaHttpCacheBundle.php b/src/bundle/IbexaHttpCacheBundle.php index d406ca4..5db443b 100644 --- a/src/bundle/IbexaHttpCacheBundle.php +++ b/src/bundle/IbexaHttpCacheBundle.php @@ -56,7 +56,7 @@ public function getContainerExtension(): ?ExtensionInterface } } - public function registerConfigParser(ContainerBuilder $container) + public function registerConfigParser(ContainerBuilder $container): void { /** @var \Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension $eZExtension */ $eZExtension = $container->getExtension('ibexa'); diff --git a/src/lib/RepositoryTagPrefix.php b/src/lib/RepositoryTagPrefix.php index ebdf493..08b7333 100644 --- a/src/lib/RepositoryTagPrefix.php +++ b/src/lib/RepositoryTagPrefix.php @@ -16,15 +16,10 @@ */ class RepositoryTagPrefix { - /** - * @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface - */ - private $resolver; + private ConfigResolverInterface $resolver; - /** - * @var int[] - */ - private $repositoryMap = []; + /** @var array */ + private array $repositoryMap = []; public function __construct(ConfigResolverInterface $resolver, array $repositories) { @@ -44,10 +39,8 @@ public function __construct(ConfigResolverInterface $resolver, array $repositori * Example: Default repository (first one), will return value "" * * WARNING: Must be called on-demand and not in constructors to avoid any issues with SiteAccess scope changes. - * - * @return string */ - public function getRepositoryPrefix() + public function getRepositoryPrefix(): string { $repositoryIdentifier = $this->resolver->getParameter('repository'); diff --git a/src/lib/Twig/ContentTaggingExtension.php b/src/lib/Twig/ContentTaggingExtension.php index 3d1804e..efcf339 100644 --- a/src/lib/Twig/ContentTaggingExtension.php +++ b/src/lib/Twig/ContentTaggingExtension.php @@ -19,11 +19,9 @@ */ class ContentTaggingExtension extends AbstractExtension { - /** @var \Ibexa\Contracts\HttpCache\ResponseTagger\ResponseTagger */ - protected $responseTagger; + protected ResponseTagger $responseTagger; - /** @var \Ibexa\Contracts\HttpCache\Handler\ContentTagInterface */ - protected $contentTagHandler; + protected ContentTagInterface $contentTagHandler; public function __construct(ResponseTagger $responseTagger, ContentTagInterface $contentTagHandler) { @@ -59,7 +57,7 @@ public function getFunctions(): array * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */ - public function tagHttpCacheForLocation(Location $location) + public function tagHttpCacheForLocation(Location $location): void { $this->responseTagger->tag($location); $this->responseTagger->tag($location->getContentInfo()); @@ -72,7 +70,7 @@ public function tagHttpCacheForLocation(Location $location) * * @param int|int[] $contentIds */ - public function tagHttpCacheForRelationIds($contentIds) + public function tagHttpCacheForRelationIds(array|int $contentIds): void { $this->contentTagHandler->addRelationTags((array)$contentIds); } @@ -84,7 +82,7 @@ public function tagHttpCacheForRelationIds($contentIds) * * @param int|int[] $locationIds */ - public function tagHttpCacheForRelationLocationIds($locationIds) + public function tagHttpCacheForRelationLocationIds(array|int $locationIds): void { $this->contentTagHandler->addRelationLocationTags((array)$locationIds); } From dd5117bf16a89f0724a6f92719b0d145880e7ba4 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 22 Nov 2024 13:35:39 +0100 Subject: [PATCH 10/14] Dropped handling obsolete service IDs from KernelPass --- .../Compiler/KernelPass.php | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/src/bundle/DependencyInjection/Compiler/KernelPass.php b/src/bundle/DependencyInjection/Compiler/KernelPass.php index f719fa9..88734f5 100644 --- a/src/bundle/DependencyInjection/Compiler/KernelPass.php +++ b/src/bundle/DependencyInjection/Compiler/KernelPass.php @@ -9,7 +9,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; /** * Disables some of the http-cache services declared by the kernel so that @@ -19,59 +18,9 @@ class KernelPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void { - foreach ($container->getDefinitions() as $id => $definition) { - if ($this->isSmartCacheListener($id) || - $this->isResponseCacheListener($id) || - $this->isCachePurger($id) - ) { - $container->removeDefinition($id); - } - } - - if ($container->hasAlias('ezpublish.http_cache.purger')) { - $container->removeAlias('ezpublish.http_cache.purger'); - } - - $this->removeKernelRoleIdContextProvider($container); + $container->removeDefinition('ezpublish.view.cache_response_listener'); // Let's re-export purge_type setting so that driver's don't have to depend on kernel in order to acquire it $container->setParameter('ibexa.http_cache.purge_type', $container->getParameter('ibexa.http_cache.purge_type')); } - - protected function removeKernelRoleIdContextProvider(ContainerBuilder $container): void - { - if (!$container->hasDefinition('ezpublish.user.identity_definer.role_id')) { - return; - } - - // As we set role identify ourselves here we remove varant from kernel if it is there. - // We don't touch ezpublish.user.hash_generator, as it's deprecated extension point by kernel - $container->removeDefinition('ezpublish.user.identity_definer.role_id'); - - // Also remove from arguments already passed to FOSHttpCache via compiler pass there. - $arguments = $container->getDefinition('fos_http_cache.user_context.hash_generator')->getArguments(); - $arguments[0] = array_values(array_filter($arguments[0], static function (Reference $argument) { - if ((string)$argument === 'ezpublish.user.identity_definer.role_id') { - return false; - } - - return true; - })); - $container->getDefinition('fos_http_cache.user_context.hash_generator')->setArguments($arguments); - } - - protected function isSmartCacheListener(string $id): bool - { - return preg_match('/^ezpublish\.cache_clear\.content.[a-z_]+_listener/', $id); - } - - protected function isResponseCacheListener(string $id): bool - { - return $id === 'ezpublish.view.cache_response_listener'; - } - - protected function isCachePurger(string $id): bool - { - return str_starts_with($id, 'ezpublish.http_cache.purger.'); - } } From d6bc2782188206c95cabf4a3102ad4369072f586 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 22 Nov 2024 13:38:08 +0100 Subject: [PATCH 11/14] [Tests] Dropped obsolete KernelPassSpec --- .../Compiler/KernelPassSpec.php | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 spec/DependencyInjection/Compiler/KernelPassSpec.php diff --git a/spec/DependencyInjection/Compiler/KernelPassSpec.php b/spec/DependencyInjection/Compiler/KernelPassSpec.php deleted file mode 100644 index 4c1c5df..0000000 --- a/spec/DependencyInjection/Compiler/KernelPassSpec.php +++ /dev/null @@ -1,62 +0,0 @@ -shouldHaveType(KernelPass::class); -// } -// -// function it_disables_the_kernels_httpcache_services(ContainerBuilder $container, Definition $hashGenerator) -// { -// $container->getAlias('ezpublish.http_cache.purge_client')->willReturn('some_random_id'); -// $container->hasAlias('ezpublish.http_cache.purger')->willReturn(true); -// $container->getAlias('ezpublish.http_cache.purger')->willReturn('some_random_id'); -// $container->getDefinitions()->willReturn([ -// 'ezpublish.http_cache.witness_service' => new Definition(), -// 'ezpublish.cache_clear.content.some_listener' => new Definition(), -// 'ezpublish.view.cache_response_listener' => new Definition(), -// 'ezpublish.http_cache.purger.some_purger' => new Definition(), -// 'ezpublish.http_cache.purger.some_other_purger' => new Definition(), -// 'witness_service' => new Definition(), -// ]); -// $container->removeDefinition('ezpublish.cache_clear.content.some_listener')->shouldBeCalled(); -// $container->removeDefinition('ezpublish.view.cache_response_listener')->shouldBeCalled(); -// $container->removeDefinition('ezpublish.http_cache.purger.some_purger')->shouldBeCalled(); -// $container->removeDefinition('ezpublish.http_cache.purger.some_other_purger')->shouldBeCalled(); -// $container->removeAlias('ezpublish.http_cache.purger')->shouldBeCalled(); -// -// $container->hasDefinition('ezpublish.user.identity_definer.role_id')->willReturn(true); -// $container->removeDefinition('ezpublish.user.identity_definer.role_id')->willReturn(true); -// $container->getDefinition('fos_http_cache.user_context.hash_generator')->willReturn($hashGenerator); -// $hashGenerator->getArguments()->willReturn([ -// [ -// $ref1 = new Reference(\Ibexa\HttpCache\ContextProvider\RoleIdentify::class), -// $ref2 = new Reference('ezpublish.user.hash_generator'), -// new Reference('ezpublish.user.identity_definer.role_id'), -// ] -// ]); -// $hashGenerator->setArguments([ -// [ -// $ref1, -// $ref2, -// ] -// ])->shouldBeCalled(); -// -// $container->getParameter('ibexa.http_cache.purge_type')->shouldBeCalled(); -// -// $this->process($container); -// } -} From 5ae4bd1d0f0b0f015e9950fb7c4d0766db5b7d42 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 22 Nov 2024 14:36:14 +0100 Subject: [PATCH 12/14] [Tests] Aligned TagHandlerSpec with Symfony 6 --- spec/Handler/TagHandlerSpec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Handler/TagHandlerSpec.php b/spec/Handler/TagHandlerSpec.php index b663459..d450589 100644 --- a/spec/Handler/TagHandlerSpec.php +++ b/spec/Handler/TagHandlerSpec.php @@ -147,7 +147,7 @@ public function it_ignores_too_long_tag_header_and_reduces_ttl(Response $respons $length += $tagLength; } $responseHeaderBag->getCacheControlDirective('s-maxage')->shouldBeCalled()->willReturn(500); - $response->setSharedMaxAge(300)->shouldBeCalled(); + $response->setSharedMaxAge(300)->shouldBeCalled()->willReturn($response); $responseHeaderBag->set('xkey', Argument::exact($underLimitTags))->shouldBeCalled(); $this->addTags(explode(' ', $underLimitTags)); From 888294c38d2108940d4531863404399da6b40041 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Fri, 22 Nov 2024 14:36:36 +0100 Subject: [PATCH 13/14] [Tests] Fixed incorrect ParameterBag being used in HttpCacheResponseSubscriberSpec --- spec/EventSubscriber/HttpCacheResponseSubscriberSpec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/EventSubscriber/HttpCacheResponseSubscriberSpec.php b/spec/EventSubscriber/HttpCacheResponseSubscriberSpec.php index d91e3b3..0124495 100644 --- a/spec/EventSubscriber/HttpCacheResponseSubscriberSpec.php +++ b/spec/EventSubscriber/HttpCacheResponseSubscriberSpec.php @@ -13,7 +13,7 @@ use Ibexa\HttpCache\ResponseConfigurator\ResponseCacheConfigurator; use PhpSpec\ObjectBehavior; use Prophecy\Argument; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\ResponseEvent; From 59dcbda769cc8bc8d75d39bda63675f7a15787d6 Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Mon, 13 Jan 2025 14:21:22 +0100 Subject: [PATCH 14/14] disabled tag by annotations as they are dependent on deprecated sensio framework extra bundle --- src/bundle/Resources/config/prepend/fos_http_cache.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bundle/Resources/config/prepend/fos_http_cache.yml b/src/bundle/Resources/config/prepend/fos_http_cache.yml index c45ef3b..68db77c 100644 --- a/src/bundle/Resources/config/prepend/fos_http_cache.yml +++ b/src/bundle/Resources/config/prepend/fos_http_cache.yml @@ -10,3 +10,7 @@ user_context: hash_cache_ttl: 600 # NOTE: These are also defined/used in AppCache, in Varnish VCL, and Fastly VCL session_name_prefix: IBX_SESSION_ID + +tags: + annotations: + enabled: false