Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Access / AccessResult.php
index 0070e089320cdb2883b4ca54bdf4d791e9ea8730..3abbf331015bf4f4a03d8d5b6f8bfe0efd506481 100644 (file)
@@ -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.
    *