Fix serialization of array values in query string parameters (2.8 backport)#47
Open
aivus wants to merge 1 commit into
Open
Fix serialization of array values in query string parameters (2.8 backport)#47aivus wants to merge 1 commit into
aivus wants to merge 1 commit into
Conversation
RequestFactory cast every query placeholder value to string, so an array value produced the literal "Array" in the request URI. Serialize arrays with http_build_query() instead, expanding them to bracket syntax (param[0]=a¶m[1]=b). Empty arrays drop the parameter entirely, with leftover query separators cleaned up. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Backport of #46 to the 2.8 release line (branch
v2.8.x, cut from tagv2.8.2) for av2.8.3patch release.Problem
RequestFactory::getRequestUri()substitutes every query placeholder withurlencode((string)$value). When a request DTO getter returns an array, the string cast produces the literal valueArrayin the request URI, so array query parameters cannot be sent at all.Fix
http_build_query(), expanding to bracket syntax (categories%5B0%5D=a&categories%5B1%5D=b) that PHP servers parse back into arrays.normalizeQueryString()cleans up leftover separators.The diff is identical to #46 (
Service/Request/RequestFactory.phpand its test are byte-identical betweenmasterandv2.8.2).Tests
Same new
RequestFactoryTestcases as #46. Full suite: 95 tests, 255 assertions, green on PHP 7.4.🤖 Generated with Claude Code