The term name argument validator has an option to convert dashes to spaces in the argument value, which means that you can have a URL like 'myview/term-name-with-spaces'.

The argument validator handles this correctly, but the query that is run with this by the term name argument is incorrect. With a simple view of article nodes and the tags field that comes OOTB with core, I get this clause in the query:

WHERE (( (taxonomy_term_field_data_node__field_tags.name = 'has-spaces') )AND(( (node_field_data.status = '1') )))
ORDER BY node_field_data_created DESC

Argument validator plugins only return a boolean from validateArgument(), but on D7 the equivalent function views_plugin_argument_validate_taxonomy_term::validate_argument() doctored the argument value on the argument handler like this:

        if ($term && (empty($vocabularies) || !empty($vocabularies[$term->machine_name]))) {
          if ($type == 'convert') {
            $this->argument->argument = $term->tid;
          }

There doesn't seem to be any provision for this in D8 -- argument validator plugins don't seem to be able to influence the argument value that the rest of the view uses.

Comments

joachim created an issue. See original summary.

joachim’s picture

Issue summary: View changes

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

@dawehner, @tim.plunkett, @alexpott, @cilefen, and I discussed this issue awhile back. We saw cases both for the issue to be major and for it to be normal. It could be a real pain point, but the available workaround is not use the feature or to have different aliases. So, deferring triage for now. It definitely is a bug.

I was surprised that there are no earlier copies of this issue, but I could not find any.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tea.time’s picture

Just to note, I'm on Drupal 8.3.0, and this works for me... (see screenshot)

johnny5th’s picture

This does not work for me on 8.3.2

jp.stacey’s picture

I can confirm I can reproduce this on 8.3.5; have, in fact, been going round in circles because I couldn't quite believe it wouldn't do what's expected!

Given this bug, what is the point of the hyphen filter? It doesn't affect the overridden title's {{ arguments.name }} and it doesn't affect the SQL.

From any site administrator's perspective, the "validation" is effectively broken, even if at some deeper level in ArgumentPluginBase::setArgument() it's technically "working". It feels like any site administrator would feel justified in considering the UI checkbox to be a "promise broken" by Drupal here, and a hit to their confidence in Drupal: why not just remove it (for now)?

jp.stacey’s picture

Here's my recent duplication of this bug on simplytest.me.

I know we already have screenshots of the SQL, but screenshots of the resulting output might help, especially comparing it to the core taxonomy/term/%tid view and showing the contextual filter configuration in the admin UI.

jp.stacey’s picture

I think this also affects the option "One or more IDs separated by , or +" - for the same reason; it's checked invalidateArgument() which does not change the argument as already set.