Entity referenced by an entity revision base field does not update search index

Created on 13 May 2022, about 2 years ago
Updated 10 September 2023, 10 months ago

Problem/Motivation

When an entity is saved, if it could be referenced by an indexed entity a lookup query is executed to find its parents. When the saved entity is referenced via an entity_revision_reference based field like the billing_profile field of the commerce_order entity ( Commerce Core β†’ ), the request fails because the property path used as a condition is billing_profile.entity whereas the entity property is not available. Note that this only happens with an entity base field not with a field added via the field API.

The exception raised:
Drupal\Core\Entity\Query\QueryException while attempting to find indexed entities referencing changed Profile with ID "1" for index Orders: 'billing_profile' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 375 of /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).

Steps to reproduce

  • Install the commerce_order module
  • Create an index of orders indexing one of the profile fields
  • Create an order with a billing profile
  • Update the profile and saved

Current behaviour: an error is triggered
Expected behaviour: the order index item is updated.

Proposed resolution

For the lookup query, we could probably replace entity_field.entity with entity_field.target_id to support entity revision reference base fields while it would still support default entity reference fields.

πŸ› Bug report
Status

Closed: duplicate

Version

1.0

Component

General code

Created by

πŸ‡¨πŸ‡­Switzerland Aerzas

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