createCollectionDataFromEntities overrides language versions

Created on 7 October 2020, over 3 years ago
Updated 3 April 2024, 3 months ago

Problem/Motivation

EntityResourceBase::createCollectionDataFromEntities stores the entities under their ids, so different language versions of the same entity are overridden by the last value.

Steps to reproduce

Pass different language versions of the same entity to EntityResourceBase::createCollectionDataFromEntities.

  1. Setup a multi-language Drupal instance.
  2. Create ~35 multi-language content nodes. Translate ~15 of those nodes.
  3. Create a JSON:API Resource endpoint; like with JSON:API Search API of that content.
  4. Access that JSON:API endpoint for that content
  5. Observe results
  6. The resulting set should return 50 items. But the actual result will be less; w/ the proper "meta: count" of the total results

Here's a comparison of the resultset from my JSON:API Search API query set vs. the collapsed result set returned from Drupal\jsonapi_resources\Resource\EntityResourceBase::createCollectionDataFromEntities. The result set count should match the query set count.

Proposed resolution

Use serial keys instead of the entity id.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Postponed

Component

Code

Created by

🇵🇱Poland blazey

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024