Loading src/Plugin/views/filter/UrlAliasFilter.php +19 −5 Original line number Diff line number Diff line Loading @@ -44,13 +44,18 @@ class UrlAliasFilter extends StringFilter { $nids[] = str_replace('/node/', '', $path); } if ($nids) { if (count($nids) === 0) { // If aliases was not found then add the condition to return nothing. $this->query->addWhere($this->options['group'], (new Condition('AND'))->alwaysFalse()); } else { $field = "$this->tableAlias.$this->realField"; $this->query->addWhere($this->options['group'], $field, $nids, 'IN'); if ($this->operator === 'empty') { $this->query->addWhere($this->options['group'], $field, $nids, 'NOT IN'); } else { // If aliases was not found then add the condition to return nothing. $this->query->addWhere($this->options['group'], (new Condition('AND'))->alwaysFalse()); $this->query->addWhere($this->options['group'], $field, $nids, 'IN'); } } } Loading Loading @@ -170,4 +175,13 @@ class UrlAliasFilter extends StringFilter { $this->queryPaths->condition($field, $this->value, 'REGEXP'); } /** * We do not add additional condition for opEmpty operator here. * * "addWhere" for "empty" operator added in the "query()" function. * Just override this method and leave it empty (to avoid an error). */ protected function opEmpty($field) { } } views_alias_filter.module +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ function views_alias_filter_views_data_alter(array &$data) { 'help' => t('Filtering nodes by URL aliases.'), 'field' => 'nid', 'id' => 'url_alias_filter', 'allow empty' => TRUE, ], ]; } Loading
src/Plugin/views/filter/UrlAliasFilter.php +19 −5 Original line number Diff line number Diff line Loading @@ -44,13 +44,18 @@ class UrlAliasFilter extends StringFilter { $nids[] = str_replace('/node/', '', $path); } if ($nids) { if (count($nids) === 0) { // If aliases was not found then add the condition to return nothing. $this->query->addWhere($this->options['group'], (new Condition('AND'))->alwaysFalse()); } else { $field = "$this->tableAlias.$this->realField"; $this->query->addWhere($this->options['group'], $field, $nids, 'IN'); if ($this->operator === 'empty') { $this->query->addWhere($this->options['group'], $field, $nids, 'NOT IN'); } else { // If aliases was not found then add the condition to return nothing. $this->query->addWhere($this->options['group'], (new Condition('AND'))->alwaysFalse()); $this->query->addWhere($this->options['group'], $field, $nids, 'IN'); } } } Loading Loading @@ -170,4 +175,13 @@ class UrlAliasFilter extends StringFilter { $this->queryPaths->condition($field, $this->value, 'REGEXP'); } /** * We do not add additional condition for opEmpty operator here. * * "addWhere" for "empty" operator added in the "query()" function. * Just override this method and leave it empty (to avoid an error). */ protected function opEmpty($field) { } }
views_alias_filter.module +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ function views_alias_filter_views_data_alter(array &$data) { 'help' => t('Filtering nodes by URL aliases.'), 'field' => 'nid', 'id' => 'url_alias_filter', 'allow empty' => TRUE, ], ]; }