Direkt zum Inhalt

Devbits

Kleine Code-Schnipsel aus unserem Alltag mit Drupal, PHP und DevOps: Problem, Lösung, Code.

10.09.2026 | Lothar Ferreira Neumann

How to delete an ECA model that throws PluginNotFoundException for a missing event/action plugin

An ECA (Event-Condition-Action) model's config can end up referencing an event, condition, or action plugin ID that no longer exists on the current site, for example, after a submodule was uninstalled or after importing a config export from an environment with different ECA submodules enabled.…

// web/modules/contrib/eca/src/Entity/Eca.php (simplified excerpt)

protected function isValidationDisabled(): bool {
  return $this->request()->query->get('eca_validation', '') === 'off';
}

public function getPluginCollections(): array {
  if ($this->isValidationDisabled()) {
    return [];
  }
  // Otherwise every referenced event/condition/action plugin is
  // instantiated here, throwing PluginNotFoundException if one
  // of them no longer exists.
  ...
}
# Delete URL — load this directly, don't click through from a listing page
/admin/config/workflow/eca/{eca_id}/delete?eca_validation=off

Issue:

An ECA (Event-Condition-Action) model's config can end up referencing an event, condition, or action plugin ID that no longer exists on the current site, for example, after a submodule was uninstalled or after importing a config export from an environment with different ECA submodules enabled. Opening that model to edit or even delete it in the ECA admin UI (/admin/config/workflow/eca) throws Drupal\Component\Plugin\Exception\PluginNotFoundException: The "..." plugin does not exist. and lands on an error page. This happens because Drupal's entity form eagerly instantiates every plugin referenced in the model as soon as it builds the entity object - even on the delete-confirmation form, before anything is submitted.

Solution:

ECA already ships a way around this: Eca::getPluginCollections() checks Eca::isValidationDisabled() which reads the eca_validation query parameter off the current request. When it's off, plugin collections are skipped entirely, so no plugin gets instantiated and the exception never fires. Load the model's edit or delete URL with ?eca_validation=off appended directly in the address bar. 

Drupal's FormBuilder copies the current request's query string into the form's #action, so the parameter survives the confirm-button POST too. The model can then be viewed, edited, or deleted cleanly, with zero code changes. Info: The parameter has to be on the URL you actually load. Clicking a normal link - e.g. the "Delete" link from the ECA listing page - navigates to a fresh URL without it, so the error still happens. 

Paste the full URL with ?eca_validation=off into the address bar instead.

13.11.2025 | Mathias Grab

How to add a Drupal error message and log entry

You would like to create a custom error message shown on the page. Also, if the error occurs, it should be properly logged in the recent log messages backend area (`/admin/reports/dblog`) of your site.

<?php

$error_message = t('There is an error with this.');

\Drupal::messenger()->addError($error_message));
\Drupal::logger('my_module')->log('error', $error_message);

Issue:

You would like to create a custom error message shown on the page. Also, if the error occurs, it should be properly logged in the recent log messages backend area (`/admin/reports/dblog`) of your site.

Solution:

Use the Drupal logger and messenger service to create the errors.

13.11.2025 | Pascal Crott

Fix broken media previews

The error log is full of the warning "Warning: copy(public://media-icons/generic/generic.png)" and the media library shows no previews. This can happen when environments are set up based on a database dump and without properly transferring the files. The media icons are usually created during the…

drush php-eval "\Drupal::moduleHandler()->loadInclude('media', 'install');media_install();";

Issue:

The error log is full of the warning "Warning: copy(public://media-icons/generic/generic.png)" and the media library shows no previews. This can happen when environments are set up based on a database dump and without properly transferring the files. The media icons are usually created during the installation of the media module, which will never happen in this scenario.

Devbit broken media preview icons

Solution:

Trigger the install hook of the Core Media module. It will take care of creating those files. Use the provided snippet.

See also https://www.drupal.org/project/drupal/issues/3060509