Issue #2387983 by Garrett Albright, larowlan: PluginNotFoundException when enabling module that provides text filter

8.0.x
Alex Pott 2015-01-04 18:15:28 +00:00
parent ab94733023
commit f562cc9b7f
4 changed files with 58 additions and 2 deletions

View File

@ -100,8 +100,14 @@ function filter_system_info_alter(&$info, Extension $file, $type) {
$used_in = [];
// Find out if any filter formats have the plugin enabled.
foreach (filter_formats() as $filter_format) {
foreach ($filter_plugins as $filter_plugin) {
if ($filter_format->filters($filter_plugin['id'])->status) {
$filters = $filter_format->filters();
// Typically, all formats will contain settings for all filter plugins,
// even if they are disabled. However, if a module which provides filter
// plugins is being enabled right now, that won't be the case, so we
// still check to see if this format has this filter before we check
// the filter status.
foreach ($filter_plugins as $filter_plugin) {
if ($filters->has($filter_plugin['id']) && $filters->get($filter_plugin['id'])->status) {
$used_in[] = $filter_format->label();
$info['required'] = TRUE;
break;

View File

@ -71,6 +71,12 @@ class FilterFormTest extends WebTestBase {
public function testFilterForm() {
$this->doFilterFormTestAsAdmin();
$this->doFilterFormTestAsNonAdmin();
// Ensure that enabling modules which provide filter plugins behaves
// correctly.
// @see https://www.drupal.org/node/2387983
\Drupal::service('module_installer')->install(['filter_test_plugin']);
// Force rebuild module data.
_system_rebuild_module_data();
}
/**

View File

@ -0,0 +1,6 @@
name: 'Filter test plugin'
type: module
description: 'Tests enabling of modules which provide filter plugins.'
package: Testing
version: VERSION
core: 8.x

View File

@ -0,0 +1,38 @@
<?php
/**
* @file
* Contains \Drupal\filter_test_plugin\Plugin\Filter\FilterSparkles.
*
* This filter does not do anything, but enabling of its module is done in a
* test.
*
* @see \Drupal\filter\Tests\FilterFormTest::testFilterForm()
*/
namespace Drupal\filter_test_plugin\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
/**
* Provides a filter to limit allowed HTML tags.
*
* @Filter(
* id = "filter_sparkles",
* title = @Translation("Sparkles filter"),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
* settings = {},
* weight = -10
* )
*/
class FilterSparkles extends FilterBase {
/**
* {@inheritdoc}
*/
public function process($text, $langcode) {
return new FilterProcessResult($text);
}
}