Skip to content

fix(api): silence api-platform legacy parameter-validator deprecation#494

Merged
turegjorup merged 1 commit into
release/3.0.0from
fix/silence-legacy-parameter-validator-deprecation
Jun 10, 2026
Merged

fix(api): silence api-platform legacy parameter-validator deprecation#494
turegjorup merged 1 commit into
release/3.0.0from
fix/silence-legacy-parameter-validator-deprecation

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Summary

API Platform 3.4 registers its legacy query-parameter validation system by default (legacy_query_parameter_validation defaults to true), and the validator classes it instantiates (ApiPlatform\ParameterValidator\Validator\Bounds et al.) call trigger_deprecation() when loaded — so every request, including plain 404s from scanner probes, logs a deprecation to the php channel in production.

This PR disables the legacy system with one config line. No behavior change: the legacy validator only enforces constraints filters declare in getDescription() (required, enum, bounds, length), and all four project filters (SharedWithMe, PublishedFilter, MultipleSearchFilter, CampaignFilter) declare required => false and none of those constraint keys — it currently enforces nothing. The modern replacement (Metadata\Parameter::$constraints) is not used in this codebase either. The component is removed entirely in API Platform 4, so this is also a small step toward that upgrade.

Files Changed

  • config/packages/api_platform.yaml - set validator.legacy_query_parameter_validation: false; drop the now-dead ApiPlatform\ParameterValidator\Exception\ValidationExceptionInterface: 400 entry from exception_to_status (nothing can throw it anymore)
  • CHANGELOG.md - entry under [Unreleased]

Test Plan

Verified locally:

  1. cache:clear, then requests to /v2/layouts (API route) and /js/twint_ch.js (the 404 probe path from the original report) — neither logs the Bounds deprecation anymore; the last occurrence in var/log/dev.log predates the change.
  2. task generate:api-spec — the exported OpenAPI spec is byte-identical (the legacy validator plays no part in spec generation), so the apispec CI gate sees no drift.
  3. CI PHPUnit suite covers the filter endpoints.

🤖 Generated with Claude Code

API Platform 3.4 registers its legacy query-parameter validation system
by default, and the validator classes it instantiates (Bounds et al.)
trigger_deprecation() on load — logging a deprecation on every request,
including plain 404s.

Disable it via legacy_query_parameter_validation: false. No behavior
change: all our filters declare required => false and none of the
constraints (enum/bounds/length) the legacy validator enforces, and the
modern replacement (Metadata\Parameter::$constraints) is not used. Also
drop the now-dead ValidationExceptionInterface exception_to_status
entry. The component is removed entirely in API Platform 4.

Verified locally: after cache:clear, API and 404 requests no longer log
the deprecation, and the exported OpenAPI spec is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@turegjorup turegjorup self-assigned this Jun 10, 2026
@turegjorup
turegjorup merged commit 31ddda2 into release/3.0.0 Jun 10, 2026
22 checks passed
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