Skip to content

fix(symfony): skip ErrorResourceAttributeLoaderPass on Symfony 6.4#8253

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/8244-symfony-64-attributeloader
Jun 5, 2026
Merged

fix(symfony): skip ErrorResourceAttributeLoaderPass on Symfony 6.4#8253
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/8244-symfony-64-attributeloader

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 5, 2026

Summary

  • Guards ErrorResourceAttributeLoaderPass against the Symfony 6.4 AttributeLoader signature (?Doctrine\Common\Annotations\Reader instead of (bool, array)), which was crashing cache warmup with a TypeError since 4.3.8.
  • Detection uses 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.
  • Also short-circuits the pass when an AttributeLoader is already wired into serializer.mapping.chain_loader (i.e. framework.serializer.enable_attributes: true), so we no longer register a duplicate loader on the default config.
  • Symfony 6.4 users keep the original Disabling symfony attributes have an impact on error decoding #8174 behavior: with enable_attributes: false, Error/ValidationException metadata won't be loaded. The 6.4 AttributeLoader has no mappedClasses filter, 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 set enable_attributes: true or upgrade to Symfony 7.x.

Fixes #8244, refs #8231, refs #8174.

Test plan

  • vendor/bin/phpunit tests/Symfony/Bundle/DependencyInjection/Compiler/ErrorResourceAttributeLoaderPassTest.php
  • New regression test: pass is a no-op when the chain already contains an AttributeLoader (enable_attributes: true path).
  • New 6.4 skip test: only runs when AnnotationLoader is present, asserts the pass leaves the chain untouched.
  • CI green on the 4.3 matrix (includes Symfony 6.4 + 7.x runs).

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
@soyuka soyuka force-pushed the fix/8244-symfony-64-attributeloader branch from b501205 to 69de470 Compare June 5, 2026 11:38
@soyuka soyuka merged commit 39edcdd into api-platform:4.3 Jun 5, 2026
110 of 112 checks passed
@soyuka soyuka deleted the fix/8244-symfony-64-attributeloader branch June 5, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant