Home Backend Development PHP Tutorial Drupal: Remove a ghost plugin from the database

Drupal: Remove a ghost plugin from the database

Jul 16, 2024 pm 01:27 PM

Drupal: Rimuovere un plugin fantasma dal database

Source: https://drupal.stackexchange.com/questions/315921/removing-phantom-plugin-from-database/320215#320215

It may happen that when you uninstall a module the procedure is not entirely carried out or there is no removal procedure present, for this reason the database remains "dirty".
Normally the error caused by the forced removal of a plugin is this:

[error]  Drupal\Component\Plugin\Exception\PluginNotFoundException:
         The "name-of-plugin" entity type does not exist.
         in Drupal\Core\Entity\EntityTypeManager->getDefinition()
Copy after login

Enabling the configuration that shows all error messages can help you understand where the error is present and where action needs to be taken.
You can activate full log enablement on the admin/config/development/logging page here. This configuration can help you figure out whether the problem is configurations or the plugin name is hard-coded into your code.

Now we will address how to resolve the problem if it is linked to configurations and to do so we have two possible ways:

  • Exporting the entire configuration and re-importing it after removing the plugin references
  • By acting directly on the configurations present in the db and removing the plugin

Exporting the entire configuration and re-importing it

This solution is most likely among the most used if you follow the standard release methodology recommended by the Drupal community.
Export the entire configuration through the graphical interface or with the drush config:export command. In the files recovered from the export, perform a full-text search with the plugin name. Remove the configuration section that is causing the error and import the configuration with drush config:import

By acting directly on the configurations present in the db and removing the plugin

This solution is useful for those who, like me, do not have the possibility of exporting the entire configuration and re-importing it but need to work "hot" on the site.
To find which configurations are causing the error you can run this query on the db:

SELECT name FROM config WHERE data LIKE "%name-of-plugin%";
Copy after login

The query searches the configuration table for the offending plugin and returns the names of the configurations that invoke the plugin.

When you have the names of the configurations you can proceed to remove the plugin.
Depending on the plugin and the configuration in error, the removal method may change slightly, now let's take into consideration an example which can also be a good starting point for other cases.

Ex.
I had a problem with the filter_image_lazy_load plugin due to a bad Drupal 10 update.
The previous query returned these configurations:

filter.format.basic_html
filter.format.full_html
filter.format.restricted_html
Copy after login

With the config.factory service I loaded the configurations and checked where the problem exists. Then you can proceed to remove the plugin like this:

$configName = 'filter.format.basic_html';
$config = \Drupal::service('config.factory')->getEditable($configName);
$filters = $config->get('filters');
unset($filters['filter_image_lazy_load']);
$config->set('filters', $filters)->save()
Copy after login

You can do the exact same thing with drush config:get filter.format.basic_html and drush config:set filter.format.basic_html or in one fell swoop with drush config:edit filter.format.basic_html

After cleaning the configurations run a drush cache:rebuild and the error should be resolved!

The above is the detailed content of Drupal: Remove a ghost plugin from the database. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey Announcement of 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

Announcement of 2025 PHP Situation Survey

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

See all articles