Handle remote entities

Created on 14 August 2024, 3 months ago

Problem/Motivation

When using remote entities, e.g. on a cross-site index, the processor will trigger exceptions, because the remote entity can't be retrieved:

Drupal\search_api\SearchApiException: The datasource with ID '192q7p--entity:node' could not be retrieved for index 'Main'. in Drupal\search_api\Entity\Index->getDatasource() (line 369 of modules/contrib/search_api/src/Entity/Index.php).

Stack trace:

#0 modules/contrib/search_api/src/Entity/Index.php(879): Drupal\search_api\Entity\Index->getDatasource()
#1 modules/contrib/search_api/src/Entity/Index.php(858): Drupal\search_api\Entity\Index->loadItemsMultiple()
#2 modules/contrib/search_api/src/Item/Item.php(203): Drupal\search_api\Entity\Index->loadItem()
#3 modules/contrib/search_api_attachments/src/Plugin/search_api/processor/FilesExtractor.php(202): Drupal\search_api\Item\Item->getOriginalObject()

Steps to reproduce

One possible scenario, very roughly: Have at least two Drupal installations write to the same index. Set up Search API Attachments for at least one of the Drupals. In a full text search view, search for a term that will show results from the one of the other Drupals.

Proposed resolution

The processor doesn't have to work for remote entities, any required processing can/will be setup at the source. Catch the exception and return. This might seem odd, but it seems to be the "official" solution, as you can see for example here as well as in other processors shipped with Search API.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs review

Version

9.0

Component

Code

Created by

🇩🇪Germany FeyP

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024