-
Notifications
You must be signed in to change notification settings - Fork 84
Fix search criteria reference #2927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
<Query> | ||
<Filter> | ||
<ContentTypeGroupIdCriterion>[1, 2]</ContentTypeGroupIdCriterion> | ||
<ContentTypeGroupIdCriterion>1</ContentTypeGroupIdCriterion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on line 38, asking to be sure - arrays work for JSON requests, but do not work for XML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ibexa/rest/blob/v5.0.2/src/lib/Server/Input/Parser/Criterion/ContentTypeGroupId.php#L31 is creating the criterion with raw data, the criterion constructor expect integer or array.
And, yes:
In JSON, arrays exist; In XML they doesn't exist.
So, the following JSON works:
{
"ViewInput": {
"identifier": "test",
"Query": {
"Filter": {
"ContentTypeGroupIdCriterion": [1, 2]
}
}
}
}
While the following XML fails:
<?xml version="1.0" encoding="UTF-8"?>
<ViewInput>
<identifier>test</identifier>
<Query>
<Filter>
<ContentTypeGroupIdCriterion>[1, 2]</ContentTypeGroupIdCriterion>
</Filter>
</Query>
</ViewInput>
The error is "ContentTypeGroupId::__construct(): Argument #1 ($value) must be of type array|int, string given".
The following works because the node value is seen as an integer somewhen betwen XML parsing and PHP type juggling:
<?xml version="1.0" encoding="UTF-8"?>
<ViewInput>
<identifier>test</identifier>
<Query>
<Filter>
<ContentTypeGroupIdCriterion>1</ContentTypeGroupIdCriterion>
</Filter>
</Query>
</ViewInput>
But there is no way to write an anonymous array in XML, you need a named tag node. That's why the ContentIdCriterion
transform the data before passing it (actually splitting string into array using coma as separator).
description: IsContainer Search Criterion | ||
--- | ||
|
||
# IsContainer Criterion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 😄 Could you please add it to the table with criterions (https://github.com/ibexa/documentation-developer/blob/5.0/docs/search/criteria_reference/search_criteria_reference.md) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> Hi, > Can you, please, add the IsContainer criterion to the search_criteria_reference.md table? Mark it available for "Content Search", "Location Search" and "Filtering". Have this new row column widths equal to the other rows of the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
* Add IsContainer criterion * visibility_criterion.md: Fix prop name in JSON * contenttypegroupid_criterion.md: Remove unrelated REST example * Fix REST ContentIdCriterion usage * contenttypegroupid_criterion.md: You can't pass an array in XML
IsContainer
criterion (found and generated during Hackathon: Unify & complete criteria reference #2923 experiment) from IBX-7653: IsContainer criterion added core#333VisibilityCriterion
JSON example (also found during Hackathon: Unify & complete criteria reference #2923)ContentIdCriterion
usage (it must be a string with ID separated by comas or you get an error with JSON, and no or wrong result with XML)ContentTypeGroupIdCriterion
XML as array doesn't exist in XML and the node string is passed as-isContentTypeGroupId
an unrelated example added in IBX-5033 REST search criteria #2040 likely by mistakedocs/search/criteria_reference/
directoryChecklist