fix(symfony): register http cache purgers independently of invalidation flag#8260
Open
soyuka wants to merge 1 commit into
Open
fix(symfony): register http cache purgers independently of invalidation flag#8260soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
…on flag When `http_cache.invalidation.enabled` is false, the bundle previously skipped loading `http_cache_purger.php`, which left the concrete purger services (`api_platform.http_cache.purger.varnish.ban`, `.varnish.xkey`, `.souin` plus the `api_platform.http_cache.purger.varnish` alias) undefined. Userland that decorates or injects those purgers — common when running multiple environments where invalidation is off in dev/test — then booted with a `ServiceNotFoundException`. Move the purger services load outside the invalidation early return, gated only on `interface_exists(PurgerInterface::class)` so missing `api-platform/http-cache` still skips cleanly. The invalidation listener (`api_platform.doctrine.listener.http_cache.purge`), the `AddTagsProcessor` state processor, the `scoped_clients` tagging, the `urls`/`varnish_urls` ScopingHttpClient wiring and the `api_platform.http_cache.purger` alias remain behind the invalidation flag — only the concrete purger classes are exposed unconditionally. Fixes api-platform#8095
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
http_cache.invalidation.enabledisfalse, the bundle previously skipped loading the concrete purger services (api_platform.http_cache.purger.varnish.ban,.varnish.xkey,.souin, plus theapi_platform.http_cache.purger.varnishalias). Userland decorating or injecting those purgers then booted with aServiceNotFoundException. This PR moves the purger services load outside the invalidation early-return — gated only oninterface_exists(PurgerInterface::class)— while keeping the listener,AddTagsProcessor, scoped HTTP-clients and theapi_platform.http_cache.purgeralias behind the invalidation flag.Reproduction
Boot a kernel with
api_platform.http_cache.invalidation.enabled: false: container compilation failed becauseapi_platform.http_cache.purger.varnish.ban(the decorated alias target) was missing.Test plan
testHttpCachePurgersRegisteredWhenInvalidationDisabled) covering the bug.testHttpCachePurgersAndListenerRegisteredWhenInvalidationEnabled) covering the unchanged path.ApiPlatformExtensionTestandtests/Symfony/Bundle/DependencyInjection/ConfigurationTeststill pass locally (the pre-existingtestSwaggerUiDisabledConfigurationfailure is unrelated and reproduces onupstream/4.3HEAD).vendor/bin/php-cs-fixer fix --dry-runandvendor/bin/phpstan analyseclean on touched files.Fixes #8095