From 23d140fd6ccfeee83d00b852a32214fab1023b4f Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 3 Mar 2017 11:37:33 +0000
Subject: [PATCH] Issue #2117305 by disasm, Pavan B S, ieguskiza, Jo
 Fitzgerald: Replace usages of db_or() and db_and()

---
 core/lib/Drupal/Core/Database/database.api.php           | 6 ++++--
 .../comment/src/Plugin/views/argument/UserUid.php        | 3 ++-
 core/modules/comment/src/Plugin/views/filter/UserUid.php | 3 ++-
 core/modules/locale/src/StringDatabaseStorage.php        | 5 +++--
 core/modules/node/src/Plugin/views/filter/Access.php     | 5 +++--
 core/modules/search/search.module                        | 3 ++-
 core/modules/search/src/Plugin/views/argument/Search.php | 5 +++--
 core/modules/search/src/Plugin/views/filter/Search.php   | 5 +++--
 core/modules/search/src/SearchQuery.php                  | 7 ++++---
 core/modules/search/src/ViewsSearchQuery.php             | 4 ++--
 .../taxonomy/src/Plugin/views/argument/IndexTidDepth.php | 3 ++-
 .../src/Plugin/views/filter/TaxonomyIndexTidDepth.php    | 3 ++-
 .../Plugin/EntityReferenceSelection/UserSelection.php    | 7 ++++---
 core/modules/user/src/Plugin/views/filter/Current.php    | 3 ++-
 core/modules/views/src/ManyToOneHelper.php               | 7 ++++---
 .../views/src/Plugin/views/display/EntityReference.php   | 4 +++-
 .../views/src/Plugin/views/filter/StringFilter.php       | 3 ++-
 core/modules/views/src/Plugin/views/query/Sql.php        | 9 +++++----
 .../KernelTests/Core/Database/SelectComplexTest.php      | 7 ++++---
 .../KernelTests/Core/Database/UpdateComplexTest.php      | 4 +++-
 20 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php
index 07e434377340..bf2f1fd3444b 100644
--- a/core/lib/Drupal/Core/Database/database.api.php
+++ b/core/lib/Drupal/Core/Database/database.api.php
@@ -5,6 +5,8 @@
  * Hooks related to the Database system and the Schema API.
  */
 
+use Drupal\Core\Database\Query\Condition;
+
 /**
  * @defgroup database Database abstraction layer
  * @{
@@ -432,11 +434,11 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que
     if (!\Drupal::currentUser()->hasPermission('bypass node access')) {
       // The node_access table has the access grants for any given node.
       $access_alias = $query->join('node_access', 'na', '%alias.nid = n.nid');
-      $or = db_or();
+      $or = new Condition('OR');
       // If any grant exists for the specified user, then user has access to the node for the specified operation.
       foreach (node_access_grants($op, $query->getMetaData('account')) as $realm => $gids) {
         foreach ($gids as $gid) {
-          $or->condition(db_and()
+          $or->condition((new Condition('AND'))
             ->condition($access_alias . '.gid', $gid)
             ->condition($access_alias . '.realm', $realm)
           );
diff --git a/core/modules/comment/src/Plugin/views/argument/UserUid.php b/core/modules/comment/src/Plugin/views/argument/UserUid.php
index cd384d560d5e..4ad41854bbd7 100644
--- a/core/modules/comment/src/Plugin/views/argument/UserUid.php
+++ b/core/modules/comment/src/Plugin/views/argument/UserUid.php
@@ -3,6 +3,7 @@
 namespace Drupal\comment\Plugin\views\argument;
 
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\Condition;
 use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -90,7 +91,7 @@ public function query($group_by = FALSE) {
       $subselect->where("c.entity_id = $this->tableAlias.$entity_id");
       $subselect->condition('c.entity_type', $entity_type);
 
-      $condition = db_or()
+      $condition = (new Condition('OR'))
         ->condition("$this->tableAlias.uid", $this->argument, '=')
         ->exists($subselect);
 
diff --git a/core/modules/comment/src/Plugin/views/filter/UserUid.php b/core/modules/comment/src/Plugin/views/filter/UserUid.php
index adee320d4403..248b4609c32a 100644
--- a/core/modules/comment/src/Plugin/views/filter/UserUid.php
+++ b/core/modules/comment/src/Plugin/views/filter/UserUid.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\comment\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\views\Plugin\views\filter\FilterPluginBase;
 
 /**
@@ -26,7 +27,7 @@ public function query() {
     $subselect->where("c.entity_id = $this->tableAlias.$entity_id");
     $subselect->condition('c.entity_type', $entity_type);
 
-    $condition = db_or()
+    $condition = (new Condition('OR'))
       ->condition("$this->tableAlias.uid", $this->value, $this->operator)
       ->exists($subselect);
 
diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php
index f925c1ad00b6..8976224b05ba 100644
--- a/core/modules/locale/src/StringDatabaseStorage.php
+++ b/core/modules/locale/src/StringDatabaseStorage.php
@@ -3,6 +3,7 @@
 namespace Drupal\locale;
 
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\Condition;
 
 /**
  * Defines a class to store localized strings in the database.
@@ -416,7 +417,7 @@ protected function dbStringSelect(array $conditions, array $options = array()) {
       elseif ($table_alias == 't' && $join === 'leftJoin') {
         // Conditions for target fields when doing an outer join only make
         // sense if we add also OR field IS NULL.
-        $query->condition(db_or()
+        $query->condition((new Condition('OR'))
           ->condition($field_alias, (array) $value, 'IN')
           ->isNull($field_alias)
         );
@@ -429,7 +430,7 @@ protected function dbStringSelect(array $conditions, array $options = array()) {
     // Process other options, string filter, query limit, etc.
     if (!empty($options['filters'])) {
       if (count($options['filters']) > 1) {
-        $filter = db_or();
+        $filter = new Condition('OR');
         $query->condition($filter);
       }
       else {
diff --git a/core/modules/node/src/Plugin/views/filter/Access.php b/core/modules/node/src/Plugin/views/filter/Access.php
index 73844e11d19b..10ae9227ae54 100644
--- a/core/modules/node/src/Plugin/views/filter/Access.php
+++ b/core/modules/node/src/Plugin/views/filter/Access.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\node\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\filter\FilterPluginBase;
 
@@ -27,10 +28,10 @@ public function query() {
     $account = $this->view->getUser();
     if (!$account->hasPermission('bypass node access')) {
       $table = $this->ensureMyTable();
-      $grants = db_or();
+      $grants = new Condition('OR');
       foreach (node_access_grants('view', $account) as $realm => $gids) {
         foreach ($gids as $gid) {
-          $grants->condition(db_and()
+          $grants->condition((new Condition('AND'))
             ->condition($table . '.gid', $gid)
             ->condition($table . '.realm', $realm)
           );
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index c36aa443d144..215a6c8d1083 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -8,6 +8,7 @@
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Cache\Cache;
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 
@@ -218,7 +219,7 @@ function search_update_totals() {
   // search_total. We use a LEFT JOIN between the two tables and keep only the
   // rows which fail to join.
   $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", array(), array('target' => 'replica'));
-  $or = db_or();
+  $or = new Condition('OR');
   foreach ($result as $word) {
     $or->condition('word', $word->realword);
   }
diff --git a/core/modules/search/src/Plugin/views/argument/Search.php b/core/modules/search/src/Plugin/views/argument/Search.php
index 9c3d6bb3ae54..c56cd09982a2 100644
--- a/core/modules/search/src/Plugin/views/argument/Search.php
+++ b/core/modules/search/src/Plugin/views/argument/Search.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\search\Plugin\views\argument;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\ViewExecutable;
@@ -76,7 +77,7 @@ public function query($group_by = FALSE) {
     else {
       $search_index = $this->ensureMyTable();
 
-      $search_condition = db_and();
+      $search_condition = new Condition('AND');
 
       // Create a new join to relate the 'search_total' table to our current 'search_index' table.
       $definition = array(
@@ -109,7 +110,7 @@ public function query($group_by = FALSE) {
       // Add the keyword conditions, as is done in
       // SearchQuery::prepareAndNormalize(), but simplified because we are
       // only concerned with relevance ranking so we do not need to normalize.
-      $or = db_or();
+      $or = new Condition('OR');
       foreach ($words as $word) {
         $or->condition("$search_index.word", $word);
       }
diff --git a/core/modules/search/src/Plugin/views/filter/Search.php b/core/modules/search/src/Plugin/views/filter/Search.php
index ea52e1cebb7f..14b14da5accc 100644
--- a/core/modules/search/src/Plugin/views/filter/Search.php
+++ b/core/modules/search/src/Plugin/views/filter/Search.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\search\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\filter\FilterPluginBase;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
@@ -150,7 +151,7 @@ public function query() {
     else {
       $search_index = $this->ensureMyTable();
 
-      $search_condition = db_and();
+      $search_condition = new Condition('AND');
 
       // Create a new join to relate the 'search_total' table to our current
       // 'search_index' table.
@@ -184,7 +185,7 @@ public function query() {
       // Add the keyword conditions, as is done in
       // SearchQuery::prepareAndNormalize(), but simplified because we are
       // only concerned with relevance ranking so we do not need to normalize.
-      $or = db_or();
+      $or = new Condition('OR');
       foreach ($words as $word) {
         $or->condition("$search_index.word", $word);
       }
diff --git a/core/modules/search/src/SearchQuery.php b/core/modules/search/src/SearchQuery.php
index 2ca2bda3a117..77ae8ff73617 100644
--- a/core/modules/search/src/SearchQuery.php
+++ b/core/modules/search/src/SearchQuery.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\search;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Database\Query\SelectExtender;
 use Drupal\Core\Database\Query\SelectInterface;
@@ -205,7 +206,7 @@ public function searchExpression($expression, $type) {
     $this->addTag('search_' . $type);
 
     // Initialize conditions and status.
-    $this->conditions = db_and();
+    $this->conditions = new Condition('AND');
     $this->status = 0;
 
     return $this;
@@ -313,7 +314,7 @@ protected function parseSearchExpression() {
         }
         $has_or = TRUE;
         $has_new_scores = FALSE;
-        $queryor = db_or();
+        $queryor = new Condition('OR');
         foreach ($key as $or) {
           list($num_new_scores) = $this->parseWord($or);
           $has_new_scores |= $num_new_scores;
@@ -401,7 +402,7 @@ public function prepareAndNormalize() {
     }
 
     // Build the basic search query: match the entered keywords.
-    $or = db_or();
+    $or = new Condition('OR');
     foreach ($this->words as $word) {
       $or->condition('i.word', $word);
     }
diff --git a/core/modules/search/src/ViewsSearchQuery.php b/core/modules/search/src/ViewsSearchQuery.php
index fc67ed172b54..e61a7e0a1c62 100644
--- a/core/modules/search/src/ViewsSearchQuery.php
+++ b/core/modules/search/src/ViewsSearchQuery.php
@@ -74,8 +74,8 @@ function conditionReplaceString($search, $replace, &$condition) {
       $conditions =& $condition['field']->conditions();
       foreach ($conditions as $key => &$subcondition) {
         if (is_numeric($key)) {
-          // As conditions can have subconditions, for example db_or(), the
-          // function has to be called recursively.
+          // As conditions can be nested, the function has to be called
+          // recursively.
           $this->conditionReplaceString($search, $replace, $subcondition);
         }
       }
diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
index 68847168f4a5..97ee5952d9c3 100644
--- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
+++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\taxonomy\Plugin\views\argument;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@@ -106,7 +107,7 @@ public function query($group_by = FALSE) {
     // Now build the subqueries.
     $subquery = db_select('taxonomy_index', 'tn');
     $subquery->addField('tn', 'nid');
-    $where = db_or()->condition('tn.tid', $tids, $operator);
+    $where = (new Condition('OR'))->condition('tn.tid', $tids, $operator);
     $last = "tn";
 
     if ($this->options['depth'] > 0) {
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
index a2b8108ffd32..ecd32eb80e88 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\taxonomy\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
@@ -72,7 +73,7 @@ public function query() {
     // Now build the subqueries.
     $subquery = db_select('taxonomy_index', 'tn');
     $subquery->addField('tn', 'nid');
-    $where = db_or()->condition('tn.tid', $this->value, $operator);
+    $where = (new Condition('OR'))->condition('tn.tid', $this->value, $operator);
     $last = "tn";
 
     if ($this->options['depth'] > 0) {
diff --git a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
index 8dfba39636d7..6043c37208e1 100644
--- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
+++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
@@ -3,6 +3,7 @@
 namespace Drupal\user\Plugin\EntityReferenceSelection;
 
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Database\Query\SelectInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
@@ -228,17 +229,17 @@ public function entityQueryAlter(SelectInterface $query) {
           // Re-add the condition and a condition on uid = 0 so that we end up
           // with a query in the form:
           // WHERE (name LIKE :name) OR (:anonymous_name LIKE :name AND uid = 0)
-          $or = db_or();
+          $or = new Condition('OR');
           $or->condition($condition['field'], $condition['value'], $condition['operator']);
           // Sadly, the Database layer doesn't allow us to build a condition
           // in the form ':placeholder = :placeholder2', because the 'field'
           // part of a condition is always escaped.
           // As a (cheap) workaround, we separately build a condition with no
           // field, and concatenate the field and the condition separately.
-          $value_part = db_and();
+          $value_part = new Condition('AND');
           $value_part->condition('anonymous_name', $condition['value'], $condition['operator']);
           $value_part->compile($this->connection, $query);
-          $or->condition(db_and()
+          $or->condition((new Condition('AND'))
             ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => \Drupal::config('user.settings')->get('anonymous')))
             ->condition('base_table.uid', 0)
           );
diff --git a/core/modules/user/src/Plugin/views/filter/Current.php b/core/modules/user/src/Plugin/views/filter/Current.php
index e7126736397f..aa42529f5a56 100644
--- a/core/modules/user/src/Plugin/views/filter/Current.php
+++ b/core/modules/user/src/Plugin/views/filter/Current.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\user\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\ViewExecutable;
 use Drupal\views\Plugin\views\filter\BooleanOperator;
@@ -28,7 +29,7 @@ public function query() {
     $this->ensureMyTable();
 
     $field = $this->tableAlias . '.' . $this->realField . ' ';
-    $or = db_or();
+    $or = new Condition('OR');
 
     if (empty($this->value)) {
       $or->condition($field, '***CURRENT_USER***', '<>');
diff --git a/core/modules/views/src/ManyToOneHelper.php b/core/modules/views/src/ManyToOneHelper.php
index a3c4834acdaf..d9ed2ca7f9bf 100644
--- a/core/modules/views/src/ManyToOneHelper.php
+++ b/core/modules/views/src/ManyToOneHelper.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\views;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\HandlerBase;
 
@@ -268,8 +269,8 @@ public function addFilter() {
       $options['group'] = 0;
     }
 
-    // add_condition determines whether a single expression is enough(FALSE) or the
-    // conditions should be added via an db_or()/db_and() (TRUE).
+    // If $add_condition is set to FALSE, a single expression is enough. If it
+    // is set to TRUE, conditions will be added.
     $add_condition = TRUE;
     if ($operator == 'not') {
       $value = NULL;
@@ -326,7 +327,7 @@ public function addFilter() {
 
     if ($add_condition) {
       $field = $this->handler->realField;
-      $clause = $operator == 'or' ? db_or() : db_and();
+      $clause = $operator == 'or' ? new Condition('OR') : new Condition('AND');
       foreach ($this->handler->tableAliases as $value => $alias) {
         $clause->condition("$alias.$field", $value);
       }
diff --git a/core/modules/views/src/Plugin/views/display/EntityReference.php b/core/modules/views/src/Plugin/views/display/EntityReference.php
index bf2d46034efb..8291378390b0 100644
--- a/core/modules/views/src/Plugin/views/display/EntityReference.php
+++ b/core/modules/views/src/Plugin/views/display/EntityReference.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\views\Plugin\views\display;
 
+use Drupal\Core\Database\Query\Condition;
+
 /**
  * The plugin that handles an EntityReference display.
  *
@@ -131,7 +133,7 @@ public function query() {
       }
 
       // Multiple search fields are OR'd together.
-      $conditions = db_or();
+      $conditions = new Condition('OR');
 
       // Build the condition using the selected search fields.
       foreach ($style_options['options']['search_fields'] as $field_id) {
diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php
index 618b58458683..68739c372087 100644
--- a/core/modules/views/src/Plugin/views/filter/StringFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\views\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
@@ -265,7 +266,7 @@ protected function opContains($field) {
   }
 
   protected function opContainsWord($field) {
-    $where = $this->operator == 'word' ? db_or() : db_and();
+    $where = $this->operator == 'word' ? new Condition('OR') : new Condition('AND');
 
     // Don't filter on empty strings.
     if (empty($this->value)) {
diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index cfe593cc2eeb..9252b6cb03a9 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
@@ -830,7 +831,7 @@ public function clearFields() {
    * @code
    * $this->query->addWhere(
    *   $this->options['group'],
-   *   db_or()
+   *   (new Condition('OR'))
    *     ->condition($field, $value, 'NOT IN')
    *     ->condition($field, $value, 'IS NULL')
    * );
@@ -1056,13 +1057,13 @@ protected function buildCondition($where = 'where') {
     $has_arguments = FALSE;
     $has_filter = FALSE;
 
-    $main_group = db_and();
-    $filter_group = $this->groupOperator == 'OR' ? db_or() : db_and();
+    $main_group = new Condition('AND');
+    $filter_group = $this->groupOperator == 'OR' ? new Condition('OR') : new Condition('AND');
 
     foreach ($this->$where as $group => $info) {
 
       if (!empty($info['conditions'])) {
-        $sub_group = $info['type'] == 'OR' ? db_or() : db_and();
+        $sub_group = $info['type'] == 'OR' ? new Condition('OR') : new Condition('AND');
         foreach ($info['conditions'] as $clause) {
           if ($clause['operator'] == 'formula') {
             $has_condition = TRUE;
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
index d6da2548237e..f10710053e7c 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\KernelTests\Core\Database;
 
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Database\RowCountException;
 use Drupal\user\Entity\User;
 
@@ -312,7 +313,7 @@ function testNestedConditions() {
     $query = db_select('test');
     $query->addField('test', 'job');
     $query->condition('name', 'Paul');
-    $query->condition(db_or()->condition('age', 26)->condition('age', 27));
+    $query->condition((new Condition('OR'))->condition('age', 26)->condition('age', 27));
 
     $job = $query->execute()->fetchField();
     $this->assertEqual($job, 'Songwriter', 'Correct data retrieved.');
@@ -395,7 +396,7 @@ function testSelectWithRowCount() {
   public function testJoinConditionObject() {
     // Same test as testDefaultJoin, but with a Condition object.
     $query = db_select('test_task', 't');
-    $join_cond = db_and()->where('t.pid = p.id');
+    $join_cond = (new Condition('AND'))->where('t.pid = p.id');
     $people_alias = $query->join('test', 'p', $join_cond);
     $name_field = $query->addField($people_alias, 'name', 'name');
     $query->addField('t', 'task', 'task');
@@ -418,7 +419,7 @@ public function testJoinConditionObject() {
     // Test a condition object that creates placeholders.
     $t1_name = 'John';
     $t2_name = 'George';
-    $join_cond = db_and()
+    $join_cond = (new Condition('AND'))
       ->condition('t1.name', $t1_name)
       ->condition('t2.name', $t2_name);
     $query = db_select('test', 't1');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php
index c2946d5c3968..e4289e6187f6 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\KernelTests\Core\Database;
 
+use Drupal\Core\Database\Query\Condition;
+
 /**
  * Tests the Update query builder, complex queries.
  *
@@ -15,7 +17,7 @@ class UpdateComplexTest extends DatabaseTestBase {
   function testOrConditionUpdate() {
     $update = db_update('test')
       ->fields(array('job' => 'Musician'))
-      ->condition(db_or()
+      ->condition((new Condition('OR'))
         ->condition('name', 'John')
         ->condition('name', 'Paul')
       );
-- 
GitLab