summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-01-22 13:36:32 (GMT)
committerAlex Pott2015-01-22 13:36:32 (GMT)
commitba831b2c56da09c1e402c4b7bf2bc3612165e565 (patch)
tree7c709c9dc83c946c5a912007deaf98c1d955f3e0
parent312aa7cf3837ba17cbe4973e71f527ef7f910cd8 (diff)
Revert "Issue #2405907 by MrHaroldA: Views combined filters add redundant separators in CONCAT_WS()"
This reverts commit 8c30ce931a50c22831ad0192bc4613bbdf33e351.
-rw-r--r--core/modules/views/src/Plugin/views/filter/Combine.php10
-rw-r--r--core/modules/views/src/Tests/Handler/FilterCombineTest.php43
2 files changed, 9 insertions, 44 deletions
diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php
index 31863c3..cad7eb9 100644
--- a/core/modules/views/src/Plugin/views/filter/Combine.php
+++ b/core/modules/views/src/Plugin/views/filter/Combine.php
@@ -77,7 +77,15 @@ class Combine extends String {
}
}
if ($fields) {
- $expression = implode(', ', $fields);
+ $count = count($fields);
+ $separated_fields = array();
+ foreach ($fields as $key => $field) {
+ $separated_fields[] = $field;
+ if ($key < $count-1) {
+ $separated_fields[] = "' '";
+ }
+ }
+ $expression = implode(', ', $separated_fields);
$expression = "CONCAT_WS(' ', $expression)";
$info = $this->operators();
diff --git a/core/modules/views/src/Tests/Handler/FilterCombineTest.php b/core/modules/views/src/Tests/Handler/FilterCombineTest.php
index 4decd83..516c773 100644
--- a/core/modules/views/src/Tests/Handler/FilterCombineTest.php
+++ b/core/modules/views/src/Tests/Handler/FilterCombineTest.php
@@ -82,49 +82,6 @@ class FilterCombineTest extends ViewUnitTestBase {
}
/**
- * Tests filtering result using a phrase that matches combined fields.
- */
- public function testFilterCombineContainsPhrase() {
- $view = Views::getView('test_view');
- $view->setDisplay();
-
- $fields = $view->displayHandlers->get('default')->getOption('fields');
- $view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
- 'job' => array(
- 'id' => 'job',
- 'table' => 'views_test_data',
- 'field' => 'job',
- 'relationship' => 'none',
- ),
- ));
-
- // Change the filtering.
- $view->displayHandlers->get('default')->overrideOption('filters', array(
- 'age' => array(
- 'id' => 'combine',
- 'table' => 'views',
- 'field' => 'combine',
- 'relationship' => 'none',
- 'operator' => 'contains',
- 'fields' => array(
- 'name',
- 'job',
- ),
- 'value' => 'ohn Si',
- ),
- ));
-
- $this->executeView($view);
- $resultset = array(
- array(
- 'name' => 'John',
- 'job' => 'Singer',
- ),
- );
- $this->assertIdenticalResultset($view, $resultset, $this->column_map);
- }
-
- /**
* Tests if the filter can handle removed fields.
*
* Tests the combined filter handler when a field overwrite is done