From b083e4075f0c8839e9ffd4e64980929f4a5763bd Mon Sep 17 00:00:00 2001 From: catch Date: Tue, 27 Sep 2022 09:55:54 +0100 Subject: [PATCH] Revert "Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query\Sql Condition classes on own class" This reverts commit 075c6914b004f0e48f9ac992d397b719e3a9876d. --- core/lib/Drupal/Core/Entity/Query/Sql/Condition.php | 11 ++--------- .../Core/Entity/Query/Sql/ConditionAggregate.php | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php b/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php index c63216b83aa..4d70b1e4564 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php @@ -25,13 +25,6 @@ class Condition extends ConditionBase { */ protected $query; - /** - * The current SQL query, set by parent condition compile() method calls. - * - * @var \Drupal\Core\Database\Query\SelectInterface - */ - protected SelectInterface $sqlQuery; - /** * {@inheritdoc} */ @@ -42,13 +35,13 @@ class Condition extends ConditionBase { // SQL query object is only necessary to pass to Query::addField() so it // can join tables as necessary. On the other hand, conditions need to be // added to the $conditionContainer object to keep grouping. - $sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $this->sqlQuery; + $sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery; $tables = $this->query->getTables($sql_query); foreach ($this->conditions as $condition) { if ($condition['field'] instanceof ConditionInterface) { $sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction()); // Add the SQL query to the object before calling this method again. - $condition['field']->sqlQuery = $sql_query; + $sql_condition->sqlQuery = $sql_query; $condition['field']->nestedInsideOrCondition = $this->nestedInsideOrCondition || strtoupper($this->conjunction) === 'OR'; $condition['field']->compile($sql_condition); $conditionContainer->condition($sql_condition); diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php index 9df8c4c2e15..75784bf11c5 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php @@ -12,13 +12,6 @@ use Drupal\Core\Entity\Query\QueryBase; */ class ConditionAggregate extends ConditionAggregateBase { - /** - * The current SQL query, set by parent condition compile() method calls. - * - * @var \Drupal\Core\Database\Query\SelectInterface - */ - protected SelectInterface $sqlQuery; - /** * {@inheritdoc} */ @@ -28,13 +21,13 @@ class ConditionAggregate extends ConditionAggregateBase { // SQL query object is only necessary to pass to Query::addField() so it // can join tables as necessary. On the other hand, conditions need to be // added to the $conditionContainer object to keep grouping. - $sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $this->sqlQuery; + $sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $conditionContainer->sqlQuery; $tables = new Tables($sql_query); foreach ($this->conditions as $condition) { if ($condition['field'] instanceof ConditionAggregateInterface) { $sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction()); // Add the SQL query to the object before calling this method again. - $condition['field']->sqlQuery = $sql_query; + $sql_condition->sqlQuery = $sql_query; $condition['field']->compile($sql_condition); $sql_query->condition($sql_condition); }