diff --git a/core/lib/Drupal/Component/Plugin/PluginBag.php b/core/lib/Drupal/Component/Plugin/PluginBag.php
index d886f36..b253bfe 100644
--- a/core/lib/Drupal/Component/Plugin/PluginBag.php
+++ b/core/lib/Drupal/Component/Plugin/PluginBag.php
@@ -111,6 +111,7 @@ public function addInstanceID($id) {
* The ID of the plugin instance to remove.
*/
public function removeInstanceID($id) {
+ $this->remove($id);
unset($this->instanceIDs[$id]);
}
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index aea0e22..318fc6b 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -469,14 +469,10 @@ function filter_get_filter_types_by_format($format_id) {
$filter_types = array();
$filters = filter_list_format($format_id);
-
- // Ignore filters that are disabled.
- $filters = array_filter($filters, function($filter) {
- return $filter->status;
- });
-
foreach ($filters as $filter) {
- $filter_types[] = $filter->getType();
+ if ($filter->status) {
+ $filter_types[] = $filter->getType();
+ }
}
return array_unique($filter_types);
diff --git a/core/modules/filter/lib/Drupal/filter/FilterBag.php b/core/modules/filter/lib/Drupal/filter/FilterBag.php
index 19cbb2c..da8d165 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterBag.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterBag.php
@@ -130,8 +130,7 @@ protected function initializePlugin($instance_id) {
* @return \Drupal\filter\FilterBag
*/
public function sort() {
- // @todo This only sorts the instances, but we have to sort the FilterBag's Iterator.
- uasort($this->pluginInstances, array($this, 'sortHelper'));
+ uasort($this->instanceIDs, array($this, 'sortHelper'));
return $this;
}
@@ -140,14 +139,16 @@ public function sort() {
*
* @see \Drupal\filter\FilterFormatStorageController::preSave()
*/
- public function sortHelper($a, $b) {
+ public function sortHelper($aID, $bID) {
+ $a = $this->get($aID);
+ $b = $this->get($bID);
if ($a->status != $b->status) {
return !empty($a->status) ? -1 : 1;
}
if ($a->weight != $b->weight) {
- return ($a->weight < $b->weight) ? -1 : 1;
+ return $a->weight < $b->weight ? -1 : 1;
}
- elseif ($a->module != $b->module) {
+ if ($a->module != $b->module) {
return strnatcasecmp($a->module, $b->module);
}
return strnatcasecmp($a->getPluginId(), $b->getPluginId());
@@ -164,7 +165,8 @@ public function sortHelper($a, $b) {
*/
public function export() {
$filters = array();
- foreach ($this->pluginInstances as $instance_id => $instance) {
+ $this->rewind();
+ foreach ($this as $instance_id => $instance) {
$filters[$instance_id] = $instance->export();
}
return $filters;
diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php
index 425b95d..4c19d8b 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php
@@ -9,7 +9,6 @@
use Drupal\Core\Config\Entity\ConfigStorageController;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Component\Utility\NestedArray;
/**
* Defines the storage controller class for Filter Format entities.
@@ -24,8 +23,11 @@ protected function preSave(EntityInterface $entity) {
$entity->name = trim($entity->label());
+ // @todo Do not save disabled filters whose properties are identical to
+ // all default properties.
+
// Determine whether the format can be cached.
- // @todo Move into FilterFormat or FilterBag.
+ // @todo This is a derived/computed definition, not configuration.
$entity->cache = TRUE;
foreach ($entity->filters() as $filter) {
if ($filter->status && !$filter->cache) {
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
index 3632e1f..f1a4abf 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
@@ -115,10 +115,8 @@ function testFormatAdmin() {
* Tests filter administration functionality.
*/
function testFilterAdmin() {
- // URL filter.
- $first_filter = 'filter_url';
- // Line filter.
- $second_filter = 'filter_autop';
+ $first_filter = 'filter_autop';
+ $second_filter = 'filter_url';
$filtered = 'filtered_html';
$full = 'full_html';
@@ -210,7 +208,6 @@ function testFilterAdmin() {
$this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), 'Full HTML format successfully updated.');
// Switch user.
- $this->drupalLogout();
$this->drupalLogin($this->web_user);
$this->drupalGet('node/add/page');
@@ -243,7 +240,6 @@ function testFilterAdmin() {
$this->assertText(check_plain($text), 'The "Plain text" text format escapes all HTML tags.');
// Switch user.
- $this->drupalLogout();
$this->drupalLogin($this->admin_user);
// Clean up.
diff --git a/core/modules/text/text.module b/core/modules/text/text.module
index 14b51e8..f006b50 100644
--- a/core/modules/text/text.module
+++ b/core/modules/text/text.module
@@ -311,7 +311,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
$line_breaks = array('
' => 6, '
' => 4);
// Newline only indicates a line break if line break converter
// filter is present.
- if (isset($filters['filter_autop'])) {
+ if ($filters->has('filter_autop') && $filters->get('filter_autop')->status) {
$line_breaks["\n"] = 1;
}
$break_points[] = $line_breaks;
@@ -339,7 +339,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
}
// If the htmlcorrector filter is present, apply it to the generated summary.
- if (isset($filters['filter_htmlcorrector'])) {
+ if ($filters->has('filter_htmlcorrector') && $filters->get('filter_htmlcorrector')->status) {
$summary = _filter_htmlcorrector($summary);
}
diff --git a/core/profiles/standard/config/filter.format.filtered_html.yml b/core/profiles/standard/config/filter.format.filtered_html.yml
index 11623fe..d2edcc1 100644
--- a/core/profiles/standard/config/filter.format.filtered_html.yml
+++ b/core/profiles/standard/config/filter.format.filtered_html.yml
@@ -7,15 +7,15 @@ roles:
- authenticated
cache: '1'
filters:
- filter_url:
- module: filter
- status: '1'
filter_html:
module: filter
status: '1'
filter_autop:
module: filter
status: '1'
+ filter_url:
+ module: filter
+ status: '1'
filter_htmlcorrector:
module: filter
status: '1'
diff --git a/core/profiles/standard/config/filter.format.full_html.yml b/core/profiles/standard/config/filter.format.full_html.yml
index 26ff727..99ed307 100644
--- a/core/profiles/standard/config/filter.format.full_html.yml
+++ b/core/profiles/standard/config/filter.format.full_html.yml
@@ -6,10 +6,10 @@ roles:
- administrator
cache: '1'
filters:
- filter_url:
+ filter_autop:
module: filter
status: '1'
- filter_autop:
+ filter_url:
module: filter
status: '1'
filter_htmlcorrector: