summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-03-06 12:48:29 (GMT)
committerNathaniel Catchpole2017-03-06 12:48:29 (GMT)
commit2135a251834eb38cefdd2da1980f46bca41358c4 (patch)
tree2ff4cb5a55f87245bcec157223fd61581ac41019
parent01f8bd64ed67a182dcf8cf155929918fbcdbee45 (diff)
Issue #2823963 by vaplas, Andrej Galuf, dawehner: Views StringFilter using 'Contains any word' or 'Contains all words' breaks query on strings containing only characters that will be trimmed
-rw-r--r--core/modules/views/src/Plugin/views/filter/StringFilter.php2
-rw-r--r--core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php36
2 files changed, 37 insertions, 1 deletions
diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php
index 733db53..a9ab5a1 100644
--- a/core/modules/views/src/Plugin/views/filter/StringFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
@@ -288,7 +288,7 @@ class StringFilter extends FilterPluginBase {
}
}
- if (!$where) {
+ if ($where->count() === 0) {
return;
}
diff --git a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
index 9ad0f88..c24cc6f 100644
--- a/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/FilterStringTest.php
@@ -293,6 +293,42 @@ class FilterStringTest extends ViewsKernelTestBase {
],
];
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
+ $view->destroy();
+
+ $view = Views::getView('test_view');
+ $view->setDisplay();
+
+ // Change the filtering to a sting containing only illegal characters.
+ $view->displayHandlers->get('default')->overrideOption('filters', [
+ 'description' => [
+ 'id' => 'description',
+ 'table' => 'views_test_data',
+ 'field' => 'description',
+ 'relationship' => 'none',
+ 'operator' => 'allwords',
+ 'value' => ':-)',
+ ],
+ ]);
+
+ $this->executeView($view);
+ $resultset = [
+ [
+ 'name' => 'Ringo',
+ ],
+ [
+ 'name' => 'John',
+ ],
+ [
+ 'name' => 'George',
+ ],
+ [
+ 'name' => 'Paul',
+ ],
+ [
+ 'name' => 'Meredith',
+ ],
+ ];
+ $this->assertIdenticalResultset($view, $resultset);
}