This issue report is taken and adapted from #3579703: Clear all derived plugin caches when an ECK entity type is created/updated.

Problem/Motivation

When a new entity type is created via config import (e.g. drush cim), the import may fail with "plugin does not exist" errors if a search index depending on that entity type is imported later in the same config import batch.

Root cause

Search API's ContentEntityDeriver derives datasource plugins dynamically from the list of available entity types (an entity:* datasource plugin per entity type). If config for e.g. a search_api.index.* is imported after the entity type config in the same batch, the plugin manager's stale cache still doesn't know about the newly created entity type, and the import fails.

Steps to reproduce

Try to import config containing both a new entity type + a search_api index using that new entity type.

You will get something like:

$ drush cim -y
[notice] Synchronized configuration: create eck.eck_entity_type.eck_example.
...
[notice] Synchronized configuration: create search_api.index.index_using_eck_example.
..
[notice] Finalizing configuration synchronization.

In ConfigImportCommands.php line 291:
  The import failed due to the following reasons:
    Unexpected error during import with operation create for search_api.index.index_using_eck_example: The "entity:eck_example" plugin does not exist. Valid plugin IDs for Drupal\search_api\Datasource\DatasourcePluginManager are: ...

In ConfigImportCommands.php line 278:
  Errors occurred during import

Proposed resolution

Ideally ContentEntityDeriver would be able to define cache tags that would make it so its definitions are automatically rebuilt at the right time, but this is not yet possible in core: #3001284: Allow plugin derivers to specify cache tags for their definitions.

A workaround could be for DatasourcePluginManager to add the entity_types cache tag to all definitions just like EntityTypeManager does.

Issue fork search_api-3579730

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dieterholvoet created an issue. See original summary.

dieterholvoet’s picture

Status: Active » Needs review