Skip to content

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Sep 29, 2025

Question Answer
JIRA Ticket
Versions
Edition

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@adriendupuis adriendupuis marked this pull request as ready for review September 30, 2025 10:04
<Query>
<Filter>
<ContentTypeGroupIdCriterion>[1, 2]</ContentTypeGroupIdCriterion>
<ContentTypeGroupIdCriterion>1</ContentTypeGroupIdCriterion>
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnocon I let Copilot do it in 617fe41

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.

> 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.
@adriendupuis adriendupuis requested a review from mnocon October 1, 2025 14:32
Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@adriendupuis adriendupuis merged commit e6a3416 into 5.0 Oct 3, 2025
7 of 8 checks passed
@adriendupuis adriendupuis deleted the fix-criteria-ref branch October 3, 2025 07:21
adriendupuis added a commit that referenced this pull request Oct 3, 2025
* 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
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