Problem/Motivation

The 'Search Results' row plugin is always available, regardless of the display type. This should work correctly with display type filtering.

E.g.

If you try to use this in a feed view, it will break too.

Steps to reproduce

  1. Go to Structure > Views > Taxonomy term > Edit > Feed
  2. Select the link "Show: Content"
  3. Expected: The "Search results" format should not be available.
  4. Actual: The option is available, and the resulting preview prints invalid markup containing ArrayArray

The same issue can also be seen for pagers right now. Again, on the feed display, all pagers are available whereas only 'basic' ('Display all items' and 'Display a specified number of items') type pagers should be available as usesPager() for the display is false.

Proposed resolution

Add a 'display_types' default value of ['normal'] to the ViewsPluginManager defaults. This will improve DX (otherwise you will always have to specify at least display_types = {"normal"} in your annotations).

We need to do this after the regular default values have been merged. Otherwise we will get arrays being concatenated during the deep merging. I.e. 'normal' will be added to every display_types array.

This can then be overridden like RestExport or Feeds do, or set to NULL if no type really is desired (this will be rare).

Remaining tasks

User interface changes

None

API changes

None

Issue fork drupal-2401637

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
3.67 KB
dawehner’s picture

Issue tags: +Needs tests
  1. +++ b/core/modules/views/src/Plugin/ViewsPluginManager.php
    @@ -46,4 +46,17 @@ public function __construct($type, \Traversable $namespaces, CacheBackendInterfa
     
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function processDefinition(&$definition, $plugin_id) {
    +    parent::processDefinition($definition, $plugin_id);
    +
    +    // Only set 'display_types' after merging if no key exists. Otherwise the
    +    // deep array merge will concatenate the two array values if it does exist.
    +    if (!array_key_exists('display_types', $definition)) {
    +      $definition['display_types'] = ['normal'];
    +    }
    +  }
    +
    

    It is too bad that we have to do that, but meh

  2. +++ b/core/modules/views/src/Plugin/views/style/DefaultStyle.php
    @@ -17,8 +17,7 @@
    + *   theme = "views_view_unformatted"
    
    +++ b/core/modules/views/src/Plugin/views/style/Grid.php
    @@ -19,8 +19,7 @@
    + *   theme = "views_view_grid"
    
    +++ b/core/modules/views/src/Plugin/views/style/HtmlList.php
    @@ -18,8 +18,7 @@
    + *   theme = "views_view_list"
    
    +++ b/core/modules/views/src/Plugin/views/style/Table.php
    @@ -22,8 +22,7 @@
    + *   theme = "views_view_table"
    

    We can now use trailing commas, isn't that awesome?

damiankloip’s picture

1. Yeah, it is that, or having some custom default handling in the the annotation classes. This feels like the better place to put this tbh.
2. Yeah, I know I know - we have been able to do this for some time. I just thought we might as well take them out to follow suit?

Let's look at some tests for this.

damiankloip’s picture

Issue summary: View changes
damiankloip’s picture

Issue tags: -Needs tests
FileSize
4.7 KB
1.03 KB

How about a quick assertion like this? To test the search specific bug in there we would need to also enable search in that test, just for the current missing display_type, so once the patch is it, it's a useless dependency anyway.

mgifford queued 5: 2401637-5.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 5: 2401637-5.patch, failed testing.

baisong’s picture

Priority: Major » Normal
Issue summary: View changes
Issue tags: +Triaged at DrupalCon Los Angeles 2015

Notes from triage with @metzlerd

  • Added steps to reproduce to summary
  • Bug is still present: Reproduced the issue on a local environment.
  • No duplicate issues found.
  • Issue category is bug because it is a regression in functionality from previous major versions or stable releases (Drupal 7.x)
  • Issue priority changed to Normal because it has isolated impact and only affects one piece of self-contained functionality, with weigh-in from @cilefen.
xjm’s picture

(Saving proposed issue credit for discussion and triage participants at LA.)

damiankloip’s picture

Priority: Normal » Major

This is definitely still an issue. Having styles showing up for displays they don't work with is a huge WTF.

Lendude’s picture

Status: Needs work » Needs review
FileSize
4.69 KB

Needed a reroll.

Currently, the wrong styles still show up in the list, but I don't see the ArrayArray stuff showing up in the markup when I select the search result option for the taxonomy feed.

But +1 for showing only stuff that's useful.

damiankloip’s picture

Yeah, the ArrayArray problem was never anything to do with this issue, so that's cool. I guess it was fixed with all the translatable markup stuff before 8.0.0 release.

Re-roll looks good to me, thanks Lendude! Another issue I forgot about!

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

cilefen’s picture

Priority: Major » Normal

@timplunkett, @alexpott, @dawehner, @xjm and I discussed this in a triage session at DrupalCon Dublin. We agree this is not ideal but if somebody uses this plugin in the wrong context the result is something weird but they should not be using the plugin in that context in the first place because it makes no sense. So, yes, it's a bug, but it isn't major.

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Version: 9.4.x-dev » 9.5.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

Confirmed this is still an issue. Needs a reroll

karishmaamin’s picture

Status: Needs work » Needs review
FileSize
5.3 KB

Re-rolled patch against 9.5.x.Please review

Status: Needs review » Needs work

The last submitted patch, 26: 2401637-26.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.45 KB
5.75 KB

Fixing test case

ambikahirode’s picture

Patch in #28 working Fine on local drupal 9.5

Manibharathi E R’s picture

Patch #28 working Fine on local Drupal 9.5.

Abhijith S’s picture

Applied patch #28 on 9.5.x and it works fine.

Before patch:
before

After patch:
after

smustgrave’s picture

If you feel the issue is fixed please move to RTBC

borisson_’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/src/Plugin/ViewsPluginManager.php
@@ -21,7 +21,7 @@ class ViewsPluginManager extends DefaultPluginManager {
+   *   keyed by the corresponding namespace to look for plugin implementations,.

,. only one should be enough I think ;)

Ratan Priya’s picture

Status: Needs work » Needs review
FileSize
5.75 KB
855 bytes

@borisson_ ,

I made the changes you required at comments #33

Needs review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

looks like isse #33 has been addressed

quietone’s picture

Removed credit for second set of screenshots on the same patch, per How is credit granted for Drupal core issues.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 34: 2401637-34.patch, failed testing. View results

borisson_’s picture

Status: Needs work » Reviewed & tested by the community

Not sure why the bot put this back to NW, last patch is still green.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Are we sure about the way we've fixed this? The current fix I think means that all display plugins in contrib have have display_types = {"normal"} in their annotation will have to be changed. If that's the fix then we need to issue a deprecation telling them that. However if we do that then I question why we don't fixed this automatically for them.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Issue tags: +Bug Smash Initiative

Patch #34 still applies to 11.x with slight fuzz but would be good to get this into MR form.

Before that happens though I think we still need an answer for #39

Lendude’s picture

The current fix changes way more than just the row plugins, as pointed out in the IS, this also affects things like pagers. This isn't necessarily a bad thing but we do need to check if we are not hiding things we don't want hidden and maybe expand the test coverage to also cover other plugin types.

For #39, I don't think plugins that have display_types = {"normal"} set need to change anything, it just becomes redundant, because we are adding display_types = {"normal"} for all plugins that don't set anything. I think....

But yeah changing this in ViewsPluginManager feels a little bit more invasive than it did when this was opened, I feel we do need a clearer list of all affected plugin types if we do it in ViewsPluginManager