diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php index 7ed5aea..9ba99f3 100644 --- a/core/modules/views/src/Plugin/views/filter/Combine.php +++ b/core/modules/views/src/Plugin/views/filter/Combine.php @@ -126,6 +126,42 @@ protected function opContains($expression) { $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%')); } + /** + * {@inheritdoc} + */ + protected function opWord($field) { + $where = $this->operator == 'word' ? db_or() : db_and(); + + // Don't filter on empty strings. + if (empty($this->value)) { + return; + } + + preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $phrase = FALSE; + // Strip off phrase quotes. + if ($match[2]{0} == '"') { + $match[2] = substr($match[2], 1, -1); + $phrase = TRUE; + } + $words = trim($match[2], ',?!();:-'); + $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY); + $placeholder = $this->placeholder(); + foreach ($words as $word) { + $where->where($field . " LIKE $placeholder", array($placeholder => '%' . db_like(trim($word, " ,!?")) . '%')); + } + } + + if (!$where) { + return; + } + + // Previously this was a call_user_func_array() but that's unnecessary + // as views will unpack an array that is a single arg. + $this->query->addWhere($this->options['group'], $where); + } + protected function opStartsWith($expression) { $placeholder = $this->placeholder(); $this->query->addWhereExpression($this->options['group'], "$expression LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));