Skip to content

Commit

Permalink
Issue #3154858 by kristiaanvandeneynde: Drupal\Core\Config\Entity\Que…
Browse files Browse the repository at this point in the history
…ry\Condition::notExists() does not work when parent property is also missing

(cherry picked from commit 87468a5d70a06aa8f7da15f339405dd6c24be9a2)
  • Loading branch information
catch committed Jul 14, 2020
1 parent d23c579 commit dd05ca5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Drupal/Core/Config/Entity/Query/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ protected function matchArray(array $condition, array $data, array $needs_matchi
return TRUE;
}
}
// If the parent does not exist, it's safe to say the actual property
// we're checking for is also NULL.
elseif ($condition['operator'] === 'IS NULL') {
return TRUE;
}
}
// Only try to match a scalar if there are no remaining keys in
// $needs_matching as this indicates that we are looking for a specific
Expand Down
10 changes: 10 additions & 0 deletions tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ public function testDotted() {
->notExists('array')
->execute();
$this->assertResults([]);
// Make sure that "IS NULL" and "IS NOT NULL" work correctly when the dotted
// path cannot be fully followed.
$this->queryResults = $this->entityStorage->getQuery()
->exists('does.not.exist')
->execute();
$this->assertResults([]);
$this->queryResults = $this->entityStorage->getQuery()
->notExists('does.not.exist')
->execute();
$this->assertResults($all);
}

/**
Expand Down

0 comments on commit dd05ca5

Please sign in to comment.