Commit 066437b8 authored by xjm's avatar xjm

Issue #2633160 by nicholasThompson, tim.plunkett: Do not fail for missing...

Issue #2633160 by nicholasThompson, tim.plunkett: Do not fail for missing context if a condition is negated
parent a0fc0b0d
......@@ -26,8 +26,9 @@ protected function resolveConditions($conditions, $condition_logic) {
$pass = $condition->execute();
}
catch (ContextException $e) {
// If a condition is missing context, consider that a fail.
$pass = FALSE;
// If a condition is missing context and is not negated, consider that a
// fail.
$pass = $condition->isNegated();
}
// If a condition fails and all conditions were needed, deny access.
......
......@@ -43,6 +43,16 @@ public function providerTestResolveConditions() {
$condition_exception->expects($this->any())
->method('execute')
->will($this->throwException(new ContextException()));
$condition_exception->expects($this->atLeastOnce())
->method('isNegated')
->will($this->returnValue(FALSE));
$condition_negated = $this->getMock('Drupal\Core\Condition\ConditionInterface');
$condition_negated->expects($this->any())
->method('execute')
->will($this->throwException(new ContextException()));
$condition_negated->expects($this->atLeastOnce())
->method('isNegated')
->will($this->returnValue(TRUE));
$conditions = array();
$data[] = array($conditions, 'and', TRUE);
......@@ -79,6 +89,14 @@ public function providerTestResolveConditions() {
$conditions = array($condition_exception, $condition_false);
$data[] = array($conditions, 'or', FALSE);
$data[] = array($conditions, 'and', FALSE);
$conditions = array($condition_negated);
$data[] = array($conditions, 'or', TRUE);
$data[] = array($conditions, 'and', TRUE);
$conditions = array($condition_negated, $condition_negated);
$data[] = array($conditions, 'or', TRUE);
$data[] = array($conditions, 'and', TRUE);
return $data;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment