diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php index d84e324..47adafb 100644 --- a/core/modules/user/src/Plugin/views/filter/Roles.php +++ b/core/modules/user/src/Plugin/views/filter/Roles.php @@ -74,6 +74,9 @@ public function operators() { */ public function calculateDependencies() { $dependencies = []; + if (in_array($this->operator, ['empty', 'not empty'])) { + return $dependencies; + } foreach ($this->value as $role_id) { $role = $this->roleStorage->load($role_id); $dependencies[$role->getConfigDependencyKey()][] = $role->getConfigDependencyName(); diff --git a/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php index 306e813..ec5a06b 100644 --- a/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php +++ b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php @@ -39,13 +39,42 @@ public function testDependencies() { 'id' => 'roles_target_id', 'table' => 'user__roles', 'field' => 'roles_target_id', + 'value' => ['test_user_role' => 'test_user_role'], + 'plugin_id' => 'user_roles', + ]; + $view->save(); + $expected['config'][] = 'user.role.test_user_role'; + $this->assertEqual($expected, $view->getDependencies()); + + $view = View::load('test_user_name'); + $display = &$view->getDisplay('default'); + $display['display_options']['filters']['roles_target_id'] = [ + 'id' => 'roles_target_id', + 'table' => 'user__roles', + 'field' => 'roles_target_id', 'value' => [ 'test_user_role' => 'test_user_role', ], + 'operator' => 'empty', + 'plugin_id' => 'user_roles', + ]; + $view->save(); + unset($expected['config']); + $this->assertEqual($expected, $view->getDependencies()); + + $view = View::load('test_user_name'); + $display = &$view->getDisplay('default'); + $display['display_options']['filters']['roles_target_id'] = [ + 'id' => 'roles_target_id', + 'table' => 'user__roles', + 'field' => 'roles_target_id', + 'value' => [ + 'test_user_role' => 'test_user_role', + ], + 'operator' => 'not empty', 'plugin_id' => 'user_roles', ]; $view->save(); - $expected['config'][] = 'user.role.test_user_role'; $this->assertEqual($expected, $view->getDependencies()); $view = Views::getView('test_user_name'); @@ -63,7 +92,6 @@ public function testDependencies() { 'plugin_id' => 'user_roles', ]; $view->save(); - unset($expected['config']); $this->assertEqual($expected, $view->getDependencies()); }