diff --git a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php index 0ef5259..0e5a57b 100644 --- a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php @@ -41,6 +41,10 @@ public function getImplementations($hook) { return array('system'); // This is called during rebuild to find testing themes. case 'system_theme_info': + // Those are needed by user_access() to check access on update.php. + case 'entity_info': + case 'entity_load': + case 'user_role_load': return array(); // t() in system_stream_wrappers() needs this. Other schema calls aren't // supported. diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index 8ad14fb..1b89aa6 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -100,12 +100,7 @@ public function hasPermission($permission) { return TRUE; } - if ($rids = $this->getRoles()) { - $roles = \Drupal::entityManager()->getStorageController('user_role')->load($this->getRoles()); - } - else { - $roles = array(); - } + $roles = \Drupal::entityManager()->getStorageController('user_role')->load($this->getRoles()); foreach ($roles as $role) { if ($role->hasPermission($permission)) { diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php index 06fe134..e0b40d7 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php @@ -376,12 +376,7 @@ public function hasPermission($permission) { return TRUE; } - if ($rids = $this->getRoles()) { - $roles = \Drupal::entityManager()->getStorageController('user_role')->load($this->getRoles()); - } - else { - $roles = array(); - } + $roles = \Drupal::entityManager()->getStorageController('user_role')->load($this->getRoles()); foreach ($roles as $role) { if ($role->hasPermission($permission)) { diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 67978a2..77e7841 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1777,7 +1777,6 @@ function user_role_revoke_permissions($rid, array $permissions = array()) { $role->revokePermission($permission); } $role->save(); - // Clear the user access cache. } function user_multiple_cancel_confirm($form, &$form_state) { diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php index dc22da1..0ce1224 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -91,7 +91,8 @@ protected function setUp() { array('last example permission', FALSE), ))); - $role_storage = $this->getMockBuilder('Drupal\User\RoleStorageController') + $role_storage = $this->getMockBuilder('Drupal\user\RoleStorageController') + ->disableOriginalConstructor() ->setMethods(array('load')) ->getMock(); $role_storage->expects($this->any()) @@ -148,12 +149,7 @@ public function testHasPermission($permission, array $sessions_with_access, arra $this->assertTrue($this->users[$name]->hasPermission($permission)); } foreach ($sessions_without_access as $name) { - try { - $this->assertFalse($this->users[$name]->hasPermission($permission)); - } - catch (\Exception $e) { - $foo = 123; - } + $this->assertFalse($this->users[$name]->hasPermission($permission)); } }