diff --git a/core/modules/filter/src/Entity/FilterFormat.php b/core/modules/filter/src/Entity/FilterFormat.php index a3f1cda..7926b58 100644 --- a/core/modules/filter/src/Entity/FilterFormat.php +++ b/core/modules/filter/src/Entity/FilterFormat.php @@ -14,7 +14,6 @@ use Drupal\filter\FilterFormatInterface; use Drupal\filter\FilterPluginCollection; use Drupal\filter\Plugin\FilterInterface; -use Drupal\user\RoleInterface; /** * Represents a text format. @@ -430,19 +429,14 @@ public function onDependencyRemoval(array $dependencies) { */ public function calculateDependencies() { parent::calculateDependencies(); - - // The permission name is FALSE when this is a fallback text format and that - // doesn't depend on any user role. - if (!$permission = $this->getPermissionName()) { - return $this->dependencies; - } - $roles = user_roles(TRUE, $permission); - // Filter out 'authenticated' role. - unset($roles[RoleInterface::AUTHENTICATED_ID]); - foreach ($roles as $rid => $role) { - $this->addDependency($role->getConfigDependencyKey(), $role->getConfigDependencyName()); + // Add user role config entities as dependencies. The permission name is + // FALSE when this is a fallback text format and that doesn't depend on any + // user role. + if ($permission = $this->getPermissionName()) { + foreach (user_roles(FALSE, $permission) as $rid => $role) { + $this->addDependency($role->getConfigDependencyKey(), $role->getConfigDependencyName()); + } } - return $this->dependencies; } diff --git a/core/modules/filter/src/Tests/FilterSettingsTest.php b/core/modules/filter/src/Tests/FilterSettingsTest.php index 21320a2..449923d 100644 --- a/core/modules/filter/src/Tests/FilterSettingsTest.php +++ b/core/modules/filter/src/Tests/FilterSettingsTest.php @@ -20,9 +20,7 @@ class FilterSettingsTest extends KernelTestBase { /** - * Modules to enable. - * - * @var array + * {@inheritdoc} */ public static $modules = ['filter', 'user', 'system']; @@ -134,6 +132,9 @@ public function testDependencies() { $this->assertIdentical(count($dependencies), 1); $this->assertTrue(in_array($roles[0]->getConfigDependencyName(), $dependencies)); $this->assertFalse(in_array($roles[1]->getConfigDependencyName(), $dependencies)); + + // The text format was not deleted on removal of dependencies. + $this->assertFalse(empty($format)); } }