diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index b914dd9..18f4ed4 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -348,7 +348,7 @@ function filter_formats($account = NULL) { $formats['all'][$format_name] = $filter_format; } } - @uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); + uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); cache()->set("filter_formats:{$language_interface->langcode}", $formats['all'], CacheBackendInterface::CACHE_PERMANENT, array('filter_formats' => TRUE)); } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php index 8cffc23..a2aec32 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php @@ -78,7 +78,15 @@ protected function postSave(EntityInterface $entity, $update) { filter_formats_reset(); // Save user role permissions. - if ($permission = filter_permission_name($entity)) { + // The format was already disabled and saved. filter_formats() does not + // include disabled formats. user_role_change_permissions() calls into + // user_permission_get_modules() which calls into hook_permission() in order + // to determine the module that defines a user permission. + // filter_permission() uses filter_formats(), so the disabled format is no + // longer contained and consequently the user permission is not found, + // leading to an error. Therefore, permissions cannot be updated for + // disabled formats. + if (!empty($entity->status) && $permission = filter_permission_name($entity)) { foreach (user_roles() as $rid => $name) { $enabled = in_array($rid, $entity->roles); user_role_change_permissions($rid, array($permission => $enabled)); diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php index f01b4d2..eab7e79 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php @@ -29,10 +29,6 @@ public static function getInfo() { ); } - function setUp() { - parent::setUp(); - } - /** * Tests hooks on format management. * @@ -55,8 +51,8 @@ function testFilterHooks() { $edit['name'] = $name; $edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 1; $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); - $this->assertRaw(t('Added text format %format.', array('%format' => $name)), 'New format created.'); - $this->assertText('hook_filter_format_insert invoked.', 'hook_filter_format_insert was invoked.'); + $this->assertRaw(t('Added text format %format.', array('%format' => $name))); + $this->assertText('hook_filter_format_insert invoked.'); $format_id = $edit['format']; @@ -64,8 +60,8 @@ function testFilterHooks() { $edit = array(); $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1; $this->drupalPost('admin/config/content/formats/' . $format_id, $edit, t('Save configuration')); - $this->assertRaw(t('The text format %format has been updated.', array('%format' => $name)), 'Format successfully updated.'); - $this->assertText('hook_filter_format_update invoked.', 'hook_filter_format_update() was invoked.'); + $this->assertRaw(t('The text format %format has been updated.', array('%format' => $name))); + $this->assertText('hook_filter_format_update invoked.'); // Use the format created. $language_not_specified = LANGUAGE_NOT_SPECIFIED; @@ -76,11 +72,11 @@ function testFilterHooks() { "body[$language_not_specified][0][format]" => $format_id, ); $this->drupalPost("node/add/{$type->type}", $edit, t('Save')); - $this->assertText(t('@type @title has been created.', array('@type' => $type_name, '@title' => $title)), 'New node successfully created.'); + $this->assertText(t('@type @title has been created.', array('@type' => $type_name, '@title' => $title))); // Disable the text format. $this->drupalPost('admin/config/content/formats/' . $format_id . '/disable', array(), t('Disable')); - $this->assertRaw(t('Disabled text format %format.', array('%format' => $name)), 'Format successfully disabled.'); - $this->assertText('hook_filter_format_disable invoked.', 'hook_filter_format_disable() was invoked.'); + $this->assertRaw(t('Disabled text format %format.', array('%format' => $name))); + $this->assertText('hook_filter_format_disable invoked.'); } }