Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
naboo opened this issue Nov 22, 2024 · 0 comments
Labels

Comments

@naboo
Copy link

naboo commented Nov 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant