- 🇺🇸United States mglaman WI, USA
Migrating some credit over from 🐛 EntityResourceBase::createCollectionDataFromEntities collapses results by $entity->id() Needs review
Although #3204303-3: EntityResourceBase::createCollectionDataFromEntities collapses results by $entity->id() → points out a possible problem:
I realize now that my proposed solution results in an invalid JSON:API schema; because translated entities share the same uuid as their default entity. And being that JSON:API result node ids (uuids) must be unique; this result is invalid.
I still believe the collapsed response is unexpected. If I request 50 items, I should receive 50 valid items (when available). I think at minimum EntityResourceBase should log a message when the unique result set does not match the given set.
- Status changed to Postponed
8 months ago 12:32pm 3 April 2024 - 🇺🇸United States mglaman WI, USA
I think the bug is really in jsonapi_search_api and its counts.
\Drupal\jsonapi_resources\Resource\EntityResourceBase::createCollectionDataFromEntities
is using\Drupal\jsonapi\Access\EntityAccessChecker::getAccessCheckedResourceObject
and ensures the translated entity is loaded via\Drupal\Core\Entity\EntityRepositoryInterface::getTranslationFromContext
.This ties into #3120437: Add optional Count data. → .
I think jsonapi_search_api needs the proper fix, and it looks like this issue is the best match 🐛 Multilingual Search shows wrong results number (especially with blank query) Active
Postponing this instead of marking as a duplicate.