fix(symfony): skip ErrorResourceAttributeLoaderPass on Symfony 6.4#8253
Merged
soyuka merged 1 commit intoJun 5, 2026
Merged
Conversation
The pass introduced in api-platform#8231 wires AttributeLoader with the Symfony 7.x constructor signature (bool $allowAnyClass, array $mappedClasses). On Symfony 6.4 the constructor is (?Doctrine\Common\Annotations\Reader), so cache warmup crashed with a TypeError on every container build. Guard the pass via class_exists(AnnotationLoader::class) — that class only exists on the 6.4 branch (removed in 7.0). Also skip the pass when an AttributeLoader is already present in the chain (enable_attributes: true) to avoid duplicating work the framework has already wired. Fixes api-platform#8244
b501205 to
69de470
Compare
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
ErrorResourceAttributeLoaderPassagainst the Symfony 6.4AttributeLoadersignature (?Doctrine\Common\Annotations\Readerinstead of(bool, array)), which was crashing cache warmup with aTypeErrorsince 4.3.8.class_exists(Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader::class)— that class only exists on the 6.4 branch (removed in 7.0), so it's a reliable version marker without depending on Composer metadata.AttributeLoaderis already wired intoserializer.mapping.chain_loader(i.e.framework.serializer.enable_attributes: true), so we no longer register a duplicate loader on the default config.enable_attributes: false, Error/ValidationException metadata won't be loaded. The 6.4AttributeLoaderhas nomappedClassesfilter, and the only way to restore it would be to re-enable global attribute discovery for every class — silently defeating the user's opt-out. They can either setenable_attributes: trueor upgrade to Symfony 7.x.Fixes #8244, refs #8231, refs #8174.
Test plan
vendor/bin/phpunit tests/Symfony/Bundle/DependencyInjection/Compiler/ErrorResourceAttributeLoaderPassTest.phpAttributeLoader(enable_attributes: truepath).AnnotationLoaderis present, asserts the pass leaves the chain untouched.