fix(jsonapi): merge flat page/itemsPerPage params with bracket filter#8193
Merged
soyuka merged 1 commit intoMay 22, 2026
Merged
Conversation
Symfony JsonApiProvider only merged `page[...]` bracket form into `_api_filters`. When a request combined a bracket filter with a flat pagination param (`?filter[name]=foo&page=2`), the scalar param was dropped: `_api_filters` ended up with only the filter, ReadProvider used it as-is, and Pagination defaulted to page 1. Links advertised the requested page, masking the regression. Pass through scalar `page`, `itemsPerPage`, `pagination`, `partial` when they are not arrays and not already populated by the bracket form. Pre-existing bracket values take precedence. Refs api-platform#7888.
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
When a JSON:API request combines a bracket-form filter with flat pagination
params (e.g.
?filter[name]=foo&page=2), the flatpagewas silently droppedand the collection always returned page 1, while pagination links still
advertised the requested page.
Root cause
Symfony\JsonApi\State\JsonApiProvideronly mergedpage[...](array form)into
_api_filters. With a scalarpage=2plus afilter[...]array, thepartial
_api_filtersset by the provider suppressedReadProvider'sfallback to
RequestParser::parseRequestParams(), soPagination::getPage()never saw the page param and returned its default of 1.
Fix
Pass through scalar
page,itemsPerPage,pagination,partialqueryparams when they are not arrays and not already populated by the bracket
form (bracket values take precedence).
Test plan
JsonApiProviderTest::testProvideMergesFlatPaginationWithBracketFilterverifies
_api_filtersends up with both the filter and the flat pagination keys.JsonApiFlatPaginationTest::testFlatPageWithBracketFilterDrivesCurrentPagehits
/dummies?filter[name]=foo&page=2withAccept: application/vnd.api+jsonand asserts
meta.currentPage === 2. The test fails without the patch(asserts that 1 === 2).
Fixes #7888.
Notes
The longer-term fix is to port JSON:API parameter handling to dedicated
ParameterProviders (Laravel already moved sort + sparse fieldset that way).An RFC for that work will follow as a separate issue against
main.