Skip to content

fix(laravel): ignore non-string values in DateFilter - #8902

Merged
soyuka merged 2 commits into
api-platform:5.0from
BenMacha:fix-laravel-date-filter-array-5-0
Dec 1, 2026
Merged

soyuka merged 2 commits into
api-platform:5.0from
BenMacha:fix-laravel-date-filter-array-5-0

Conversation

@BenMacha

Copy link
Copy Markdown
Contributor
Q A
Branch? 5.0
Tickets -
License MIT
Doc PR -

The Laravel DateFilter returns a 500 when an operator gets an array instead of a string:

GET /api/books?publicationDate[gt][]=2024-01-01
  • before: 500, TypeError: DateFilter::getDateTime(): Argument #1 ($value) must be of type string, array given
  • after: 200, the invalid value is ignored, like an unparsable date already is

The Doctrine DateFilterTrait already skips non-string values, and no validation rule protects this parameter on the Laravel side (its schema type is date). The fix makes getDateTime() return null for anything that is not a string. Covered by testDateFilterIgnoresNonStringValue in src/Laravel/Tests/EloquentTest.php.

A nested array such as ?publicationDate[gt][]=2024-01-01 reached DateFilter::getDateTime(string)
and raised a TypeError (500). Non-string values are now ignored, like the Doctrine DateFilter
does.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T08:59:04.064180Z df1cea2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BenMacha
BenMacha force-pushed the fix-laravel-date-filter-array-5-0 branch from df1cea2 to 78a8c8e Compare November 30, 2026 12:35
@soyuka
soyuka merged commit 31bc7ea into api-platform:5.0 Dec 1, 2026
4 of 115 checks passed
@soyuka

soyuka commented Dec 1, 2026

Copy link
Copy Markdown
Member

thanks @BenMacha!

soyuka pushed a commit that referenced this pull request Dec 1, 2026
…ls (#8913)

Since 4e3343e (#8902) each loop checks the
value type itself, but only the default loop was covered.
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.

2 participants