Commit f562cc9b authored by alexpott's avatar alexpott

Issue #2387983 by Garrett Albright, larowlan: PluginNotFoundException when...

Issue #2387983 by Garrett Albright, larowlan: PluginNotFoundException when enabling module that provides text filter
parent ab947330
......@@ -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;
......
......@@ -71,6 +71,12 @@ protected function setUp() {
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();
}
/**
......
name: 'Filter test plugin'
type: module
description: 'Tests enabling of modules which provide filter plugins.'
package: Testing
version: VERSION
core: 8.x
<?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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment