Skip to content

Conversation

barw4
Copy link
Contributor

@barw4 barw4 commented Aug 12, 2025

🎫 Issue IBX-10458

Caution

Table/column names/aliases mergup.

Description:

The ContentTypeService contract has been extended with a new method:

    public function findContentTypes(?ContentTypeQuery $query = null, array $prioritizedLanguages = []): SearchResult;

The ContentTypeQuery object receives the following arguments:

        ?CriterionInterface $criterion = null,
        array $sortClauses = [],
        int $offset = 0,
        int $limit = 25

And the available criterions are:

  • ContainsFieldDefinitionIds (joins field definitions and validates if a content type contains them)
  • ContentTypeGroupIds (joins content type group assignment table and searches for provided group ids)
  • Identifiers (content type identifiers)
  • Ids (content type ids)
  • IsSystem (joins content type group table via content type group assignment table and validates if group is system or not)
  • LogicalAnd
  • LogicalOr
  • LogicalNot

There are also available the following sort clauses:

  • Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Id
  • Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Identifiers

Examplary query:

            new ContentTypeQuery(
                new LogicalOr([
                    new LogicalAnd([
                        new ContentTypeIdentifier(['folder', 'article']),
                        new ContentTypeGroupId([1]),
                    ]),
                    new ContentTypeIdentifier(['user']),
                ]),
            ),

For QA:

Documentation:

@barw4 barw4 self-assigned this Aug 12, 2025
@barw4 barw4 added the Feature New feature request label Aug 12, 2025
@barw4 barw4 force-pushed the ibx-10458-content-type-search-papi branch from 701a49c to 5c19221 Compare August 12, 2025 08:06
@barw4 barw4 marked this pull request as ready for review August 13, 2025 08:30
@barw4 barw4 requested a review from a team August 13, 2025 08:31
@ezrobot ezrobot requested review from adamwojs, mikadamczyk, Steveb-p, alongosz, ciastektk, ViniTou, wiewiurdp, konradoboza and tbialcz and removed request for a team August 13, 2025 08:31
Copy link
Member

@adamwojs adamwojs left a comment

Choose a reason for hiding this comment

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

Let's focus first on establishing final shape of the contracts.

@barw4 barw4 requested a review from adamwojs August 18, 2025 08:26
@barw4 barw4 force-pushed the ibx-10458-content-type-search-papi branch from b3df6c4 to 0859ce5 Compare August 20, 2025 11:59
@barw4 barw4 requested a review from adamwojs August 20, 2025 12:52
@mnocon mnocon added the Doc needed The changes require some documentation label Sep 2, 2025
@barw4 barw4 force-pushed the ibx-10458-content-type-search-papi branch from d25bd08 to 7242b33 Compare September 9, 2025 09:11
@barw4 barw4 requested review from alongosz and Steveb-p September 10, 2025 08:05
Comment on lines +1526 to +1529
foreach ($query->getSortClauses() as $sortClause) {
$column = sprintf('c.%s', $sortClause->target);
$joinedQueryBuilder->addOrderBy($column, $this->getQuerySortingDirection($sortClause->direction));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is sorting done on the second query, not on the one where you actually acquire IDs?

When done in the 2nd query, assuming that LIMIT caused later results to be discarded, the order of results will be incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't it the opposite? When I sort in the first query, I get sorted ids, correct. But do I have a guarantee that results in second query are sorted when fetched with WHERE IN and without a sort clause? Tests show that I need to sort the second query.

@barw4 barw4 requested a review from Steveb-p September 10, 2025 08:21
/**
* @param list<int>|int $value
*/
public function __construct($value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an easy way to make it either array or int and not both? Would that provide to many limitations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could potentially create second property and type it properly, but I'm not sure if that won't overcomplicate stuff

$queryBuilder
->select(
[
'c.id AS ezcontentclass_id',
Copy link
Contributor

Choose a reason for hiding this comment

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

remember that we also changed those aliases - either, if possible, rename them now to ibexa_ or if those relay on exsiting mappers - remember to do it on mergeup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They rely on the mappers, but I'll keep in mind to change it during mergup, thanks!

@barw4 barw4 force-pushed the ibx-10458-content-type-search-papi branch from f96e9a3 to 69eebef Compare September 21, 2025 14:16
@barw4 barw4 force-pushed the ibx-10458-content-type-search-papi branch from 69eebef to 6d12b78 Compare September 23, 2025 10:31
Copy link

@barw4 barw4 requested a review from ViniTou September 23, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc needed The changes require some documentation Feature New feature request Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants