$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());
}
}
$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);
/**
* 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.
*