Skip to content

feat(symfony): deprecate Symfony Security AccessDeniedException#8318

Merged
soyuka merged 3 commits into
api-platform:mainfrom
soyuka:feat/deprecate-symfony-access-denied-exception
Jun 17, 2026
Merged

feat(symfony): deprecate Symfony Security AccessDeniedException#8318
soyuka merged 3 commits into
api-platform:mainfrom
soyuka:feat/deprecate-symfony-access-denied-exception

Conversation

@soyuka

@soyuka soyuka commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

Deprecates ApiPlatform\Symfony\Security\Exception\AccessDeniedException in favor of ApiPlatform\Metadata\Exception\AccessDeniedException. Adds an @deprecated tag plus a trigger_deprecation('api-platform/core', '4.4', ...) in a new constructor that mirrors the base Symfony exception signature, so existing new AccessDeniedException(...) callers are unaffected (no BC break).

The internal self-throw in AccessCheckerProvider is baselined rather than migrated: swapping it to the Metadata replacement would change the thrown type (Security AccessDeniedExceptionAccessDeniedHttpException lineage), a behavioral/BC change deferred to 5.0.

Roadmap

Part of the 4.4 preparation. Spec: TODO-4.4-5.0.md §C.3, §B.2 (folds in T18 — same symbol, no second deprecation site).
Phase: 4.4 (additive / deprecation-only, no BC break).

Test plan

  • @group legacy-style test asserts the deprecation message via expectUserDeprecationMessage and that base exception behavior (message / previous / 403 status / headers) is preserved.
  • Targeted suites pass locally (46 tests: dedicated + AccessCheckerProviderTest + functional DenyTest/IsGrantedTest).
  • Deprecation baseline clean (--fail-on-deprecation --use-baseline=phpunit.baseline.xml).

soyuka added 3 commits June 17, 2026 11:11
Deprecate ApiPlatform\Symfony\Security\Exception\AccessDeniedException in favor of
ApiPlatform\Metadata\Exception\AccessDeniedException. Adds an @deprecated tag plus a
trigger_deprecation in a new constructor mirroring the base Symfony signature (no BC break).
The internal self-throw in AccessCheckerProvider is baselined; migrating it changes the
thrown type and is 5.0 work.

Refs TODO-4.4-5.0.md §C.3, §B.2.
…ows do not self-trigger

The 4.4 deprecation self-triggered on every denied REST request because
AccessCheckerProvider throws this class internally; baselining the ctor line then
suppressed the same deprecation the dedicated test asserts, breaking CI.

Add a triggerDeprecation ctor flag (default true, BC-safe) and pass false from the
internal REST throw, so api-platform does not nag users for its own use while external
instantiation still triggers. Drop the now-unnecessary phpunit.baseline.xml entry.
…nt suite

The dedicated deprecation test ran in the root tests/ dir, collected by the
full-suite "PHPUnit (PHP 8.x)" jobs alongside ApiTestCase + full kernel. In
that environment the exception/deprecation handler stack is polluted by other
tests (cf. PR api-platform#7949), so expectUserDeprecationMessage captured nothing and the
test failed with "Expected deprecation ... was not triggered". It passed only
when run standalone.

Relocate it into the isolated Symfony component suite under src/Symfony/Tests/,
matching the proven idiom (Group('legacy') + IgnoreDeprecations) used by every
working expectUserDeprecationMessage test in the repo. No production change.
@soyuka soyuka merged commit c9e5071 into api-platform:main Jun 17, 2026
84 of 96 checks passed
@soyuka soyuka deleted the feat/deprecate-symfony-access-denied-exception branch June 17, 2026 18:30
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