Skip to content

[5.x]: Eager loading of multiple added fields return the same entries for a related field #16191

@naboo

Description

@naboo

What happened?

Description

I have an entry in my PRODUCTS section which has a ENTRIES field added to it to load an entry from my COLLECTION section. My collection entry then has two ENTRIES field added to it (using the same field) but with two different handles.

When running this code to fetch the related eager-loaded entries from the collection entry they return the same entries even if one of the fields doesn't even have entries selected.

{% set collection = entry.collectionEntry.eagerly().one() %}
{% set relatedEntries = collection.relatedEntries.eagerly().all() %}
{% set moreRelatedEntries = collection.moreRelatedEntries.eagerly().all() %}

... so "relatedEntries" and "moreRelatedEntries" pull the same entries - but only entries are selected for field "moreRelatedEntries". They are both the same field added to the section COLLECTION multiple times.

Related to: #15890

Expected behavior

Only the actual entries selected in the related ENTRIES field type should return for each specific field.

Craft CMS version

5.5.x

PHP version

8.3

Operating system and version

Ubuntu 22.x

Database type and version

MySQL 8.0+

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions