From 0f5cb7935273e9b66c2d79a67fa7c61f128c41b8 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 12 Dec 2022 15:48:14 +0000
Subject: [PATCH] Issue #2810985 by _Archy_, smustgrave, GoZ, joelpittet,
 csheltonlcm, ayush.khare, Lendude: Remove duplicate condition

(cherry picked from commit 803264a258ad50ae4ffd21c411da43d3bca3fe78)
---
 .../views/src/Plugin/views/filter/Combine.php |  2 +-
 .../src/Kernel/Handler/FilterCombineTest.php  | 55 +++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php
index b541009c3dea..d1e25f167590 100644
--- a/core/modules/views/src/Plugin/views/filter/Combine.php
+++ b/core/modules/views/src/Plugin/views/filter/Combine.php
@@ -71,7 +71,7 @@ public function query() {
       $field = $this->view->field[$id];
       // Always add the table of the selected fields to be sure a table alias exists.
       $field->ensureMyTable();
-      if (!empty($field->field_alias) && !empty($field->field_alias)) {
+      if (!empty($field->tableAlias) && !empty($field->realField)) {
         $fields[] = "$field->tableAlias.$field->realField";
       }
     }
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php
index 6d5b71742d92..d1a577fab5e5 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php
@@ -569,6 +569,61 @@ public function testFilterCombineNot() {
     $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
   }
 
+  /**
+   * Tests the combine filter when no realName is used.
+   */
+  public function testFilterCombineNoRealName() {
+    $view = Views::getView('test_view');
+    $view->setDisplay();
+
+    $fields = $view->displayHandlers->get('default')->getOption('fields');
+    $view->displayHandlers->get('default')->overrideOption('fields', $fields + [
+      'name_no_id' => [
+        'id' => 'name_no_id',
+        'table' => 'views_test_data',
+        'field' => 'name_fail',
+        'relationship' => 'none',
+      ],
+    ]);
+
+    // Change the filtering.
+    $view->displayHandlers->get('default')->overrideOption('filters', [
+      'age' => [
+        'id' => 'combine',
+        'table' => 'views',
+        'field' => 'combine',
+        'relationship' => 'none',
+        'operator' => 'contains',
+        'fields' => [
+          'name_no_id',
+          'job',
+        ],
+        'value' => 'iNg',
+      ],
+    ]);
+
+    $this->executeView($view);
+    $resultset = [
+      [
+        'name' => 'John',
+        'job' => 'Singer',
+      ],
+      [
+        'name' => 'George',
+        'job' => 'Singer',
+      ],
+      [
+        'name' => 'Ringo',
+        'job' => 'Drummer',
+      ],
+      [
+        'name' => 'Ginger',
+        'job' => NULL,
+      ],
+    ];
+    $this->assertNotIdenticalResultset($view, $resultset, $this->columnMap);
+  }
+
   /**
    * Additional data to test the NULL issue.
    */
-- 
GitLab