Fix FilesExtractor when indexing items without a top-level entity

Created on 4 June 2024, 5 months ago
Updated 19 June 2024, 5 months ago

Problem/Motivation

When running the indexing, FilesExtractor::addFieldValues is called and tries to load the entity so that it can pull the file attachments from it.

It does this by calling $item->getOriginalObject()->getValue() and assuming that an entity has been returned. However there is no guarantee that an entity will be returned, so this causes an error while indexing when `$entity->getEntityTypeId()` runs.

Steps to reproduce

Add a datasource that returns an array rather than a specfic entity. https://www.drupal.org/sandbox/sam/3200275 would most likely work.
Add a content datasouce with a file attachement
Configure Search API attachments to index files in the standard way
Clear and run the index
Observe error Call to a member function getEntityTypeId() on array

Proposed resolution

Stop further processing of the item there is no entity.

Another option could be a configuraton value to choose which datasources the attachment extracting runs on.

Remaining tasks

MR
Approve
Merge

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Fixed

Version

9.0

Component

Code

Created by

🇳🇿New Zealand danielveza Brisbane, AU

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