Causes Views with Contextual filter and default set to query parameter to ignore the contextual filters with OR

Created on 18 June 2025, about 2 months ago

Problem/Motivation

When the Trash module is installed and is enabled for content, it causes views with contextual filters that get the default value from a query parameter fail.

Steps to reproduce

  1. git clone https://git.drupalcode.org/project/drupal.git
  2. composer install
  3. composer require drush/drush
  4. composer require drupal/views_contextual_filters_or:^1.5
  5. drush site:install -y
  6. drush en views_contextual_filters_or
  7. Create Article content
  8. Create a Views block with contextual filter for the title and provide default by query parameter (e.g. param)
  9. Edit view with contextual filter for the body and provide a second default by query parameter (same as the first - param)
  10. Edit view and check [Advanced - Other - Query settings - Contextual filters OR] box
  11. place block in block layout (it won't show in preview when editing the view)
  12. Visit page and confirm query returns expected results
  13. composer require drupal/trash
  14. composer install
  15. drush en trash
  16. Check [Enabled entity types content] box on /admin/config/content/trash page
  17. clear cache
  18. navigate to page block is on
  19. the or contextual filters are ignored
๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @serverjohn
  • ๐Ÿ‡ท๐Ÿ‡ดRomania amateescu

    I tried to reproduce this using the steps in the issue summary and I couldn't get the view to display anything after adding the second contextual filter. Can you please update the steps with actual values? Even node title and values for the body field would help to ensure that I'm testing your specific scenario.

    And you can leave out the parts about adding the modules, installing the site, etc. as they're not necessary :)

  • I am no longer able to produce the problem as described above. I do still have an instance of a full blown site that has this problem. I have been messing around with composer trying to get the proper versions of things that I had in place but I lack the experience necessary. It seems to be a problem with this combination:

    • drupal 11.1.8
    • trash 3.0.16
    • views_contextual_filters_or 8.x-1.5

    Here is an updated action list:

    1. Create and Article with "Test" in the title and body fields
    2. Create a Views page for the Article content type with the following
      settings:
      1. Page settings > Path > test-query-parameter-and-trash-module
      2. Advanced > Contextual filters > add > Title / Content
        1. Configure contextual filter: Content: Title
          1. When the filter value is NOT in the URL > Provide default
            value
          2. Type > Query parameter
          3. Query parameter > param
      3. Advanced > Contextual filters > add > Body (body) / Content
        1. Configure contextual filter: Content: Body (body)
          1. When the filter value is NOT in the URL > Provide default
            value
          2. Type > Query parameter
          3. Query parameter > param
      4. Advanced > Other > Query settings > Contextual filters OR > checked
    3. Navigate to /test-query-parameter-and-trash-module/?param=test
      1. You should see the article created with test in the title and body
    4. Install the Trash module
    5. Navigate to /test-query-parameter-and-trash-module/?param=test

    And here is the view config:

    uuid: 7a10f1eb-ce0f-470b-b6fd-be8b85090aa1
    langcode: en
    status: true
    dependencies:
      config:
        - core.entity_view_mode.node.teaser
        - node.type.article
      module:
        - node
        - user
    id: test_query_parameter_and_trash_module
    label: 'Test query parameter and Trash module'
    module: views
    description: ''
    tag: ''
    base_table: node_field_data
    base_field: nid
    display:
      default:
        id: default
        display_title: Default
        display_plugin: default
        position: 0
        display_options:
          title: 'Test query parameter and Trash module'
          fields:
            title:
              id: title
              table: node_field_data
              field: title
              relationship: none
              group_type: group
              admin_label: ''
              entity_type: node
              entity_field: title
              plugin_id: field
              label: ''
              exclude: false
              alter:
                alter_text: false
                make_link: false
                absolute: false
                word_boundary: false
                ellipsis: false
                strip_tags: false
                trim: false
                html: false
              element_type: ''
              element_class: ''
              element_label_type: ''
              element_label_class: ''
              element_label_colon: false
              element_wrapper_type: ''
              element_wrapper_class: ''
              element_default_classes: true
              empty: ''
              hide_empty: false
              empty_zero: false
              hide_alter_empty: true
              click_sort_column: value
              type: string
              settings:
                link_to_entity: true
              group_column: value
              group_columns: {  }
              group_rows: true
              delta_limit: 0
              delta_offset: 0
              delta_reversed: false
              delta_first_last: false
              multi_type: separator
              separator: ', '
              field_api_classes: false
          pager:
            type: mini
            options:
              offset: 0
              pagination_heading_level: h4
              items_per_page: 10
              total_pages: null
              id: 0
              tags:
                next: โ€บโ€บ
                previous: โ€นโ€น
              expose:
                items_per_page: false
                items_per_page_label: 'Items per page'
                items_per_page_options: '5, 10, 25, 50'
                items_per_page_options_all: false
                items_per_page_options_all_label: '- All -'
                offset: false
                offset_label: Offset
          exposed_form:
            type: basic
            options:
              submit_button: Apply
              reset_button: false
              reset_button_label: Reset
              exposed_sorts_label: 'Sort by'
              expose_sort_order: true
              sort_asc_label: Asc
              sort_desc_label: Desc
          access:
            type: perm
            options:
              perm: 'access content'
          cache:
            type: tag
            options: {  }
          empty: {  }
          sorts:
            created:
              id: created
              table: node_field_data
              field: created
              relationship: none
              group_type: group
              admin_label: ''
              entity_type: node
              entity_field: created
              plugin_id: date
              order: DESC
              expose:
                label: ''
                field_identifier: ''
              exposed: false
              granularity: second
          arguments:
            title:
              id: title
              table: node_field_data
              field: title
              relationship: none
              group_type: group
              admin_label: ''
              entity_type: node
              entity_field: title
              plugin_id: string
              default_action: default
              exception:
                value: all
                title_enable: false
                title: All
              title_enable: false
              title: ''
              default_argument_type: query_parameter
              default_argument_options:
                query_param: param
                fallback: ''
                multiple: and
              summary_options:
                base_path: ''
                count: true
                override: false
                items_per_page: 25
              summary:
                sort_order: asc
                number_of_records: 0
                format: default_summary
              specify_validation: false
              validate:
                type: none
                fail: 'not found'
              validate_options: {  }
              glossary: false
              limit: 0
              case: none
              path_case: none
              transform_dash: false
              break_phrase: false
            body_value:
              id: body_value
              table: node__body
              field: body_value
              relationship: none
              group_type: group
              admin_label: ''
              plugin_id: string
              default_action: default
              exception:
                value: all
                title_enable: false
                title: All
              title_enable: false
              title: ''
              default_argument_type: query_parameter
              default_argument_options:
                query_param: param
                fallback: ''
                multiple: and
              summary_options:
                base_path: ''
                count: true
                override: false
                items_per_page: 25
              summary:
                sort_order: asc
                number_of_records: 0
                format: default_summary
              specify_validation: false
              validate:
                type: none
                fail: 'not found'
              validate_options: {  }
              glossary: false
              limit: 0
              case: none
              path_case: none
              transform_dash: false
              break_phrase: false
          filters:
            status:
              id: status
              table: node_field_data
              field: status
              entity_type: node
              entity_field: status
              plugin_id: boolean
              value: '1'
              group: 1
              expose:
                operator: ''
            type:
              id: type
              table: node_field_data
              field: type
              entity_type: node
              entity_field: type
              plugin_id: bundle
              value:
                article: article
          style:
            type: table
            options:
              grouping: {  }
              row_class: ''
              default_row_class: true
              columns:
                title: title
              default: '-1'
              info:
                title:
                  sortable: false
                  default_sort_order: asc
                  align: ''
                  separator: ''
                  empty_column: false
                  responsive: ''
              override: true
              sticky: false
              summary: ''
              empty_table: false
              caption: ''
              description: ''
              class: ''
          row:
            type: 'entity:node'
            options:
              view_mode: teaser
          query:
            type: views_query
            options:
              query_comment: ''
              disable_sql_rewrite: false
              distinct: false
              replica: false
              query_tags: {  }
              contextual_filters_or: true
          relationships: {  }
          group_by: true
          header: {  }
          footer: {  }
          display_extenders: {  }
        cache_metadata:
          max-age: -1
          contexts:
            - 'languages:language_content'
            - 'languages:language_interface'
            - url
            - url.query_args
            - 'user.node_grants:view'
            - user.permissions
          tags: {  }
      block_1:
        id: block_1
        display_title: Block
        display_plugin: block
        position: 2
        display_options:
          exposed_block: true
          display_extenders: {  }
        cache_metadata:
          max-age: -1
          contexts:
            - 'languages:language_content'
            - 'languages:language_interface'
            - url
            - url.query_args
            - 'user.node_grants:view'
            - user.permissions
          tags: {  }
      page_1:
        id: page_1
        display_title: Page
        display_plugin: page
        position: 1
        display_options:
          display_extenders: {  }
          path: test-query-parameter-and-trash-module
        cache_metadata:
          max-age: -1
          contexts:
            - 'languages:language_content'
            - 'languages:language_interface'
            - url
            - url.query_args
            - 'user.node_grants:view'
            - user.permissions
          tags: {  }
    
  • I am closing this. I have unsuccessfully tried to reproduce this. I do have a site with many other modules installed where uninstalling the trash module allows the contextual or filter to work. However, a very basic site build no longer presents the problem. I'm not sure what changed. I even pulled up the initial build, from the first comment, that I still had on another computer. That also, no longer showed the problem as described. ::shrug::

    Maybe it was the gremlins... or maybe I am just crazy...

Production build 0.71.5 2024