fix(metadata): stop alerting on inline unwired filters at warmup - #8490
Merged
soyuka merged 2 commits intoSep 1, 2026
Merged
Conversation
…to debug An inline filter instance passed to a query parameter is never wired with a manager registry, unlike a filter resolved as a service. Reading its legacy description during cache warmup then fails on the Doctrine metadata lookup. This is expected and recoverable, yet it was logged at alert level, spamming one line per such parameter on every cache clear and misleading unrelated diagnostics. Log this known warmup case at debug level, keeping alert for genuinely unexpected registry failures. Closes api-platform#7361 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 2c82381)
api-platform/metadata does not depend on api-platform/doctrine-common, so a fixture using ManagerRegistryAwareTrait makes the split package's test suite fatal on "Trait ... not found". Move the coverage to doctrine-orm, where both are available, and exercise a real unwired DateFilter instead of a hand-rolled stand-in.
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.
Supersedes #8408 by @alexisLefebvre, whose commit is cherry-picked here (the diagnosis and the fix are his).
What
An inline filter instance passed to a
QueryParameteris never wired with aManagerRegistry, unlike a filter resolved as a service through the filter locator. Reading its legacy description during metadata build therefore throws, gets caught, and is logged atalert— one identicalALERT ManagerRegistry must be initialized before accessing it.line per parameter on everycache:clear. Filtering itself is unaffected:ParameterExtensionwires the registry at query time.That failure is expected on this path, so it is now logged at
debug. ARuntimeExceptionfrom any other cause — a filter that is notManagerRegistryAware, or one that is already wired — still logs atalert.Why this shape
The condition is knowable before calling
getLegacyFilterMetadata(), so an earlyreturnlooked tempting. It is not safe: a userland filter extendingAbstractFilter(henceManagerRegistryAwareInterface) may overridegetDescription()with something that needs no registry, and skipping would silently drop its description. Downgrading inside thecatchonly changes the level of a message on a path that already failed, so nothing that works today changes.Note this does not go away on its own for the surviving filters: on
main,DateFilteris standalone but stilluse ManagerRegistryAwareTrait, andDateFilterTrait::getDescription()still callsgetClassMetadata(). Users migrated to the canonical filters (ExactFilter,SortFilter,ComparisonFilter, …) are already unaffected —BackwardCompatibleFilterDescriptionTraitreturns an empty description and never touches Doctrine.Tests
src/Doctrine/Orm/Tests/Metadata/Resource/UnwiredLegacyFilterParameterTest.phpdrives a realnew QueryParameter(filter: new DateFilter())— the exact declaration from the issue — and assertsdebugrather thanalert, plus a second case pinning that an unrelated failure still alerts. It lives in doctrine-orm rather than metadata becauseapi-platform/metadatadoes not depend onapi-platform/doctrine-common, so a fixture usingManagerRegistryAwareTraitwould make the split package's suite fatal.