diff --git a/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php index 70b9bee..74d7cc6 100644 --- a/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php +++ b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php @@ -47,7 +47,7 @@ public function compile($conditionContainer) { $type = $or || $condition['operator'] == 'IS NULL' ? 'LEFT' : 'INNER'; #$this->translateCondition($condition); if ($and || !$added) { - $alias = $conditionContainer->join('config_entity_denormalized', NULL, '%alias.entity_type = base_table.entity_type AND %alias.entity_id = base_table.entity_id'); + $alias = $sqlQuery->join('config_entity_denormalized', NULL, '%alias.entity_type = base_table.entity_type AND %alias.entity_id = base_table.entity_id'); $added = TRUE; } if ($and) { diff --git a/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php b/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php index 434ca06..fa69fc8 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php @@ -20,17 +20,19 @@ class ConfigEntityQueryTest extends DrupalUnitTestBase { static $modules = array('config_test'); /** + * Stores the search results for alter comparision. + * * @var array */ protected $queryResults; /** - * @var \Drupal\entity\Query\QueryFactory + * @var \Drupal\Core\Entity\Query */ protected $factory; /** - * All config entities created for that test. + * Stores all config entities created for that test. * * @var array */ @@ -177,6 +179,21 @@ public function testConfigEntityQuery() { ->condition('id', 2) ->execute(); $this->assertEqual(count($this->queryResults), 2); + + // Filters an OR condition group which both contain an AND group. + $query = $this->factory->get('config_test', 'OR'); + $and_condition_1 = $query->andConditionGroup() + ->condition('id', 1) + ->condition('label', $this->entities[0]->label); + $and_condition_2 = $query->andConditionGroup() + ->condition('id', 2) + ->condition('label', $this->entities[1]->label); + $this->factory->get('config_test', 'OR') + ->condition($and_condition_1) + ->condition($and_condition_2) + ->execute(); + $this->assertEqual(count($this->queryResults), 2); + $this->assertEqual($this->queryResults, array(1 => 1, 2 => 2)); } /**