Automatically remove Gutenberg Blocks text format during uninstall

Created on 15 July 2019, over 5 years ago
Updated 30 July 2024, 6 months ago

Currently, we are not able to uninstall module because of the:

Provides a filter plugin that is in use in the following filter formats: Gutenberg Blocks text format

Removing the filter shouldn't be done manually. It could be handled in hook_uninstall

✨ Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡΅πŸ‡±Poland sayco ToruΕ„

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Could try adding a hook_uninstall to gutenberg/gutenberg.install

    Please try adding this hook_uninstall to your gutenberg.install file and then rebuild cache, uninstall the module and see if this works.

    /**
     * Implements hook_uninstall().
     */
    function gutenberg_uninstall() {
      // Remove the filter from all text formats.
      $config_factory = \Drupal::configFactory();
      $text_formats = \Drupal\filter\Entity\FilterFormat::loadMultiple();
    
      foreach ($text_formats as $format) {
        $config = $config_factory->getEditable('filter.format.' . $format->id());
        $filters = $config->get('filters');
    
        if (isset($filters['gutenberg'])) {
          unset($filters['gutenberg']);
          $config->set('filters', $filters)->save();
        }
      }
    }
    
  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 6 months ago
  • πŸ‡΅πŸ‡ΉPortugal marcofernandes

    We already have something similar at the hook_uninstall. The issue is that Gutenberg can't be uninstalled while its filter plugin is being used in the Gutenberg text format.
    Not sure if Drupal has some kind of "force" mechanism for uninstalling modules.
    Another solution would be try to add a button at the uninstall page to remove that text format.

Production build 0.71.5 2024