Skip to content

Conversation

adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Nov 20, 2024

Question Answer
JIRA Ticket N/A
Versions 5.0
Edition All

To get all relations, use RelationListIteratorAdapter + BatchIterator instead of ContentService::countRelations() + ContentService::loadRelationList()

Follows #2544 and in particular this comment.

Previews:

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

Fix "Argument #1 ($contentId) must be of type int, string given"
loadRelations is deprecated in 4.5, and removed in 5.0

Fix "Call to an undefined method Ibexa\Contracts\Core\Repository\ContentService::loadRelations()." on PHPStan + 5.0
loadRelations is deprecated in 4.5, and removed in 5.0

Fix "Call to an undefined method Ibexa\Contracts\Core\Repository\ContentService::loadRelations()." on PHPStan + 5.0
@adriendupuis adriendupuis added the Wait with merge PRs that shouldn't be merged instantly label Nov 21, 2024
# Conflicts:
#	code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php
#	code_samples/front/embed_content/src/Controller/RelationController.php
#	docs/content_management/content_api/browsing_content.md
@mnocon mnocon changed the base branch from master to 5.0 May 19, 2025 07:33
@adriendupuis adriendupuis removed the Wait with merge PRs that shouldn't be merged instantly label May 20, 2025
# Conflicts:
#	docs/content_management/content_api/browsing_content.md
Copy link

github-actions bot commented Jun 6, 2025

# Conflicts:
#	docs/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIteratorAdapter-RelationListIteratorAdapter.html
@adriendupuis adriendupuis marked this pull request as ready for review July 22, 2025 10:13
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.

No comments about the code, looks solid 💪

Only one suggestion about the wording, as it's not clear to me right now.

Comment on lines 96 to 98
To list Relations to and from your content, you can to pass a `VersionInfo` object to the [`ContentService::loadRelationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadRelationList) method which is paginated.
Or you can use the [`RelationListIteratorAdapter`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIteratorAdapter-RelationListIteratorAdapter.html) within a [`BatchIterator`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html).
This method loads only the specified subset of relations to improve performance and was created with pagination in mind.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To list Relations to and from your content, you can to pass a `VersionInfo` object to the [`ContentService::loadRelationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadRelationList) method which is paginated.
Or you can use the [`RelationListIteratorAdapter`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIteratorAdapter-RelationListIteratorAdapter.html) within a [`BatchIterator`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html).
This method loads only the specified subset of relations to improve performance and was created with pagination in mind.
To list Relations to and from your content, you can to pass a `VersionInfo` object to the [`ContentService::loadRelationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadRelationList) method.
This method loads only the specified subset of relations to improve performance and was created with pagination in mind.
Alternatively, use the [`RelationListIteratorAdapter`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIteratorAdapter-RelationListIteratorAdapter.html) within a [`BatchIterator`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html) to iterate over all relations.

I suggest to rewrite this part somehow.

First we mention the loadRelationList,then we mention RelationListIteratorAdapter object, only to start the next sentence with "This method` - so we're back to discussing loadRelationList?

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 Thank you for this highlight. That effectively doesn't make much sense. With the "you can to pass" grammar issue and this sentence about "pagination in mind" that doesn't sound like something I would write, there is clearly an issue here.

I rewrite this in d025c0c
https://ez-systems-developer-documentation--2548.com.readthedocs.build/en/2548/content_management/content_api/browsing_content/#relations

@adriendupuis adriendupuis requested a review from mnocon July 22, 2025 14:58
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.

I'd mention https://doc.ibexa.co/en/latest/search/search_api/#processing-large-result-sets for people not familiar with it (I've found this page only recently, when adjusting the code samples for v5)


- pass a `VersionInfo` object to the [`ContentService::loadRelationList` method](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadRelationList) which returns a slice of the relation list thanks to pagination arguments
- use the [`RelationListIteratorAdapter`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIteratorAdapter-RelationListIteratorAdapter.html)
within a [`BatchIterator`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html) which allow traversing the relation list using one same object
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
within a [`BatchIterator`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html) which allow traversing the relation list using one same object
within a [`BatchIterator`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Iterator-BatchIterator.html) which allows traversing the whole relation list
See [Processing large result sets](search_api.md#processing-large-result-sets) for more information about the BatchIterator.

Could you please add the RelationListAdapter to the list of Adapters on https://doc.ibexa.co/en/latest/search/search_api/#processing-large-result-sets ?

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