X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FAccess%2FAccessResult.php;h=3abbf331015bf4f4a03d8d5b6f8bfe0efd506481;hb=refs%2Fheads%2Fd864;hp=0070e089320cdb2883b4ca54bdf4d791e9ea8730;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Access/AccessResult.php b/web/core/lib/Drupal/Core/Access/AccessResult.php index 0070e0893..3abbf3310 100644 --- a/web/core/lib/Drupal/Core/Access/AccessResult.php +++ b/web/core/lib/Drupal/Core/Access/AccessResult.php @@ -336,10 +336,10 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable $merge_other = TRUE; } - if ($this->isForbidden() && $this instanceof AccessResultReasonInterface) { + if ($this->isForbidden() && $this instanceof AccessResultReasonInterface && !is_null($this->getReason())) { $result->setReason($this->getReason()); } - elseif ($other->isForbidden() && $other instanceof AccessResultReasonInterface) { + elseif ($other->isForbidden() && $other instanceof AccessResultReasonInterface && !is_null($other->getReason())) { $result->setReason($other->getReason()); } } @@ -353,14 +353,13 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable $result = static::neutral(); if (!$this->isNeutral() || ($this->getCacheMaxAge() === 0 && $other->isNeutral()) || ($this->getCacheMaxAge() !== 0 && $other instanceof CacheableDependencyInterface && $other->getCacheMaxAge() !== 0)) { $merge_other = TRUE; - if ($other instanceof AccessResultReasonInterface) { - $result->setReason($other->getReason()); - } } - else { - if ($this instanceof AccessResultReasonInterface) { - $result->setReason($this->getReason()); - } + + if ($this instanceof AccessResultReasonInterface && !is_null($this->getReason())) { + $result->setReason($this->getReason()); + } + elseif ($other instanceof AccessResultReasonInterface && !is_null($other->getReason())) { + $result->setReason($other->getReason()); } } $result->inheritCacheability($this); @@ -427,9 +426,9 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable /** * Inherits the cacheability of the other access result, if any. * - * inheritCacheability() differs from addCacheableDependency() in how it - * handles max-age, because it is designed to inherit the cacheability of the - * second operand in the andIf() and orIf() operations. There, the situation + * This method differs from addCacheableDependency() in how it handles + * max-age, because it is designed to inherit the cacheability of the second + * operand in the andIf() and orIf() operations. There, the situation * "allowed, max-age=0 OR allowed, max-age=1000" needs to yield max-age 1000 * as the end result. *