diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index d7c62e3..26530a6 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -152,8 +152,8 @@ protected function cacheId(EntityInterface $entity, $operation, $langcode = LANG protected function getCache(EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { // @todo Remove this once we can rely on $account. $account = $account ?: user_load($GLOBALS['user']->uid); - $cid = $this->cacheId($entity, $operation, $langcode, $account); - $uid = $account->id(); + $cid = $this->cacheId($entity, $operation, $langcode, $account ?: NULL); + $uid = $account ? $account->id() : 0; // Return from cache if a value has been set for it previously. if (isset($this->accessCache[$uid][$cid][$langcode][$operation])) { @@ -182,8 +182,8 @@ protected function getCache(EntityInterface $entity, $operation, $langcode = LAN protected function setCache($access, EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { // @todo Remove this once we can rely on $account. $account = $account ?: user_load($GLOBALS['user']->uid); - $cid = $this->cacheId($entity, $operation, $langcode, $account); - $uid = $account->id(); + $cid = $this->cacheId($entity, $operation, $langcode, $account ?: NULL); + $uid = $account ? $account->id() : 0; // Save the given value in the static cache and directly return it. return $this->accessCache[$uid][$cid][$langcode][$operation] = (bool) $access;