[pp-1] SearchApiException: Unknown datasource plugin with ID 'entity:FOO' during config import

Created on 13 January 2024, 12 months ago
Updated 14 February 2024, 10 months ago

Problem/Motivation

During config import, when Drupal is trying to create a view related to a search_api index for a external entity type, and when the external entity type and the search api index are new and are being created as part of the same config_import, the search api datasource plugin is not recognized because the list of plugins got cached previously and it won't be refreshed until you clear the cache.
Clearing the cache and trying the config import again will fix the issue, but can cause problems during automatic deployment or during CI process, causing the following error:

Fatal error: Uncaught Drupal\search_api\SearchApiException: Unknown datasource plugin with ID 'entity:FOO' in /.../web/modules/contrib/search_api/src/Utility/PluginHelper.php:81

In the error message the external entity type name has been replaced by FOO as an example.

Steps to reproduce

- Create a database dump
- Create an external entity type
- Create a search api index for the new external entity type
- Create a view for the new search api index
- Export the configuration
- Drop the database and import the sql dump created in the first step
- Import the configuration, the error will happen

Proposed resolution

- Apply the patch on 🐛 Statically cached derivative definitions cannot be cleared in any way RTBC to Drupal core
- Clear the cached definitions of the search api datasource plugins when a new external entity type gets created

Remaining tasks

- Wait for the Drupal core patch to be committed
- Patch
- Review
- Test

User interface changes

- None

API changes

- None

Data model changes

- None

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇪🇸Spain akalam

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