The entity_lookup plugin should preserve the source order

Created on 5 December 2016, almost 8 years ago
Updated 7 March 2024, 8 months ago

The Destination field is not guaranteed to store the entities found in the same order as the destination lists them.

For example, Suppose the source has a Category term reference field with term names of Product, Foo, Foo-blue stored in that order. Passing the term names to the entity_lookup plugin will cause the destination entity created to have the destination field stored in this order: Foo, Foo blue, Product

This is because for multiple values, a single query with "IN" is used for multiple values in EntityLookup->query method. The results of an 'in' set, will have whatever the ordering of the index used to look them up. Generally alphabetical / numeric ascending.

Order of entities in the fields is important for a lot of reasons. E.g., matching the taxonomy hierarchy, ordering related posts by most relative, ordering paragraphs correctly, and the like.

The fix for this is to perform individual queries to find the values and then aggregate them in the proper order.

Patch attached in the next comment.

πŸ› Bug report
Status

Needs work

Version

6.0

Component

Plugins

Created by

πŸ‡ΊπŸ‡ΈUnited States cgmonroe

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.71.5 2024