diff --git a/core/modules/filter/src/Entity/FilterFormat.php b/core/modules/filter/src/Entity/FilterFormat.php index 1df794e..b477d65 100644 --- a/core/modules/filter/src/Entity/FilterFormat.php +++ b/core/modules/filter/src/Entity/FilterFormat.php @@ -424,13 +424,9 @@ public function onDependencyRemoval(array $dependencies) { */ public function calculateDependencies() { parent::calculateDependencies(); - // Add user role config entities as dependencies. The permission name is - // FALSE when this is a fallback text format and that doesn't create any - // dependency on user roles. - if (($rids = $this->get('roles')) && $permission = $this->getPermissionName()) { - foreach (Role::loadMultiple($rids) as $role) { - $this->addDependency($role->getConfigDependencyKey(), $role->getConfigDependencyName()); - } + // Add user role config entities as dependencies. + foreach (Role::loadMultiple($this->get('roles')) as $role) { + $this->addDependency($role->getConfigDependencyKey(), $role->getConfigDependencyName()); } return $this->dependencies; } diff --git a/core/modules/filter/src/FilterFormatFormBase.php b/core/modules/filter/src/FilterFormatFormBase.php index 0d64c8a..a8b4973 100644 --- a/core/modules/filter/src/FilterFormatFormBase.php +++ b/core/modules/filter/src/FilterFormatFormBase.php @@ -216,7 +216,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $form_state->setValueForElement($form['name'], $format_name); // Normalize roles by converting the list from 'checkboxes' values format to - // a simple indexed list, having unchecked values filtered out. + // a simple indexed list, having the unchecked values filtered out. $is_fallback = $format_format == $this->config('filter.settings')->get('fallback_format'); $roles = $is_fallback ? [] : array_values(array_filter($form_state->getValue('roles'))); $form_state->setValueForElement($form['roles'], $roles); diff --git a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php index daef17b..a9e60cb 100644 --- a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php +++ b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php @@ -46,8 +46,8 @@ function testInstallation() { // Verify that format default property values have been added/injected. $this->assertTrue($format->uuid()); - // Verify that the loaded format does not contain any roles. - $this->assertEqual($format->get('roles'), NULL); + // The loaded format contains the roles supplied in the default config. + $this->assertEqual($format->get('roles'), array(RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID)); // Verify that the defined roles in the default config have been processed. $this->assertEqual(array_keys(filter_get_roles_by_format($format)), array( RoleInterface::ANONYMOUS_ID, @@ -89,10 +89,9 @@ function testUpdateRoles() { )); $format->save(); - // Verify that roles have not been updated. + // Verify if the roles have been updated. $format = entity_load('filter_format', 'filter_test'); $this->assertEqual(array_keys(filter_get_roles_by_format($format)), array( - RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID, )); } diff --git a/core/modules/filter/src/Tests/FilterSettingsTest.php b/core/modules/filter/src/Tests/FilterSettingsTest.php index 37b20a4..22cf009 100644 --- a/core/modules/filter/src/Tests/FilterSettingsTest.php +++ b/core/modules/filter/src/Tests/FilterSettingsTest.php @@ -72,9 +72,9 @@ public function testDependencies() { $factory = $this->container->get('config.factory'); $this->installEntitySchema('user'); - // Create 2 arbitrary roles allowed to use the text format $format. /** @var \Drupal\user\RoleInterface[] $roles */ $roles = []; + // Create 2 arbitrary roles. for ($i = 0; $i < 2; $i++) { $roles[$i] = Role::create([ 'id' => Unicode::strtolower($this->randomMachineName()), @@ -111,7 +111,7 @@ public function testDependencies() { // text format is the fallback format. $this->assertTrue(empty($format->getDependencies()['config'])); - // Set the fallback format to different format. + // Set the fallback format to a different, arbitrary, format. $settings ->set('fallback_format', Unicode::strtolower($this->randomMachineName())) ->save();