reverted: --- b/core/modules/rest/tests/src/Functional/Update/EntityResourcePermissionsUpdateTest.php +++ a/core/modules/rest/tests/src/Functional/Update/EntityResourcePermissionsUpdateTest.php @@ -33,6 +33,8 @@ * Tests rest_update_8203(). */ public function testBcEntityResourcePermissionSettingAdded() { + $permission_handler = $this->container->get('user.permissions'); + $is_rest_resource_permission = function ($permission) { return $permission['provider'] === 'rest' && (string) $permission['title'] !== 'Administer REST resource configuration'; }; @@ -40,18 +42,15 @@ // Make sure we have the expected values before the update. $rest_settings = $this->config('rest.settings'); $this->assertFalse(array_key_exists('bc_entity_resource_permissions', $rest_settings->getRawData())); + $this->assertEqual([], array_filter($permission_handler->getPermissions(), $is_rest_resource_permission)); - $this->assertEqual([], array_filter($this->container->get('user.permissions')->getPermissions(), $is_rest_resource_permission)); $this->runUpdates(); - // Running updates changes the available permissions, clear the static - // cache. - $this->container->set('user.permissions', NULL); // Make sure we have the expected values after the update. $rest_settings = $this->config('rest.settings'); $this->assertTrue(array_key_exists('bc_entity_resource_permissions', $rest_settings->getRawData())); $this->assertTrue($rest_settings->get('bc_entity_resource_permissions')); + $rest_permissions = array_keys(array_filter($permission_handler->getPermissions(), $is_rest_resource_permission)); - $rest_permissions = array_keys(array_filter($this->container->get('user.permissions')->getPermissions(), $is_rest_resource_permission)); $this->assertEqual(['restful delete entity:node', 'restful get entity:node', 'restful patch entity:node', 'restful post entity:node'], $rest_permissions); } diff -u b/core/modules/user/user.module b/core/modules/user/user.module --- b/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1294,23 +1294,11 @@ } /** - * Implements hook_modules_installed(). - */ -function user_modules_installed($modules) { - // Reset the user.permissions service to reset statically cached - // permissions. - \Drupal::getContainer()->set('user.permissions', NULL); -} - -/** * Implements hook_modules_uninstalled(). */ function user_modules_uninstalled($modules) { // Remove any potentially orphan module data stored for users. \Drupal::service('user.data')->delete($modules); - // Reset the user.permissions service to reset statically cached - // permissions. - \Drupal::getContainer()->set('user.permissions', NULL); } /** @@ -1363,11 +1351,23 @@ } /** + * Implements hook_modules_installed(). + */ +function user_modules_installed($modules) { + // Reset the user.permissions service to reset statically cached + // permissions. + \Drupal::getContainer()->set('user.permissions', NULL); +} + +/** * Implements hook_modules_uninstalled(). */ function user_modules_uninstalled($modules) { // Remove any potentially orphan module data stored for users. \Drupal::service('user.data')->delete($modules); + // Reset the user.permissions service to reset statically cached + // permissions. + \Drupal::getContainer()->set('user.permissions', NULL); } /**