[php-nextgen] Fix object query parameters given as a model, fixes #24684 - #24685
Merged
wing328 merged 3 commits intoAug 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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.
Fixes the query serialization of object-typed parameters when the value is a generated model
instance.
fix #24684
PR checklist
@jebentier @dkarlovi @mandrean @jfastnacht @ybelenko @renepardon
What was wrong
ObjectSerializer::toQueryValue()prepared object-typed values with a plain(array)cast:Generated models keep their values in a single
protected array $container, not in publicproperties, so casting a model with
(array)yields PHP's mangled property name(
"\0*\0container") as the only key instead of the model's fields. The result was a query stringthe server cannot interpret, produced silently.
Given this spec:
and
new Filter(['requirements' => [1, 2], 'status' => 'published']):The fix
Object-typed values now go through
sanitizeForSerialization(), which for anything implementingModelInterfacewalksopenAPITypes(), calls the real getters and keys the result byattributeMap()— the same mechanism already used for JSON request bodies. Query and bodyserialization therefore share one code path, and this keeps working for any future model without
further special-casing. Plain arrays and scalars keep the original
(array)cast, so nothing elsechanges.
sanitizeForSerialization()returns an object at every level, while the$flattenArraystep belowdispatches on
is_array(), so the object graph is converted to arrays first via a small recursivetoArrayRecursive()helper. A shallow(array)cast is not sufficient: nested models stay objectsand later fail with
Object of class stdClass could not be converted to string.Summary by cubic
Fix query serialization for object and model-typed parameters when the value is a generated model. Models now serialize via getters instead of a shallow array cast, producing correct deepObject and form query strings. Fixes #24684.
sanitizeForSerialization()with a recursivetoArrayRecursive().Written for commit e89ccac. Summary will update on new commits.