[SOLVED] Logic error in views SQL query since updating to Drupal 10.1.4

Created on 2 October 2023, over 1 year ago

Problem/Motivation

When I updated my site to Drupal 10.1.4 last week, apparently one of my site's views broke. I can see that the logic of the query that drupal created based on the view has changed, and that the new version is definitely not what the authors specified. I wonder if this is a known issue? If not, any thoughts on how to resolve it?

I will paste the configuration for the view below. In the meantime, here are the old (working) and new (broken) versions of the SQL query:
WORKING:

SELECT "node_field_data"."created" AS "node_field_data_created", "node_field_data"."nid" AS "nid"
FROM
{node_field_data} "node_field_data"
LEFT OUTER JOIN {node__field_article_type} "node__field_article_type" ON node_field_data.nid = node__field_article_type.entity_id AND node__field_article_type.deleted = '0'
WHERE (((node__field_article_type.field_article_type_value = 'news')) OR ("node_field_data"."type" != 'article')) AND (("node_field_data"."status" = '1') AND ("node_field_data"."type" IN ('article', 'external_headline', 'pdf_news')))
ORDER BY "node_field_data_created" DESC
LIMIT 6 OFFSET 0

BROKEN:

SELECT "node_field_data"."created" AS "node_field_data_created", "node_field_data"."nid" AS "nid"
FROM
{node_field_data} "node_field_data"
LEFT OUTER JOIN {node__field_article_type} "node__field_article_type" ON node_field_data.nid = node__field_article_type.entity_id AND node__field_article_type.deleted = '0'
WHERE (((node__field_article_type.field_article_type_value = 'news')) OR ("node_field_data"."type" != 'article')) AND (("node_field_data"."status" = '1') AND ("node_field_data"."type" IN ('article', 'external_headline', 'pdf_news')))
ORDER BY "node_field_data_created" DESC
LIMIT 6 OFFSET 0

And here is the configuration for the node that is generating the bad query:

uuid: 06fc048c-8a09-4386-92db-2907aae39076
langcode: en
status: true
dependencies:
  config:
    - core.entity_view_mode.node.teaser
    - field.storage.node.field_article_excerpt
    - field.storage.node.field_description
    - field.storage.node.field_full_name
    - field.storage.node.field_news_source
    - field.storage.node.field_preview_image
    - node.type.article
    - node.type.external_headline
    - node.type.pdf_news
    - responsive_image.styles.teaser_images
    - taxonomy.vocabulary.topics
  module:
    - better_exposed_filters
    - node
    - options
    - responsive_image
    - taxonomy
    - user
    - views_infinite_scroll
id: latest_news
label: 'Latest News'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
display:
  default:
    id: default
    display_title: Master
    display_plugin: default
    position: 0
    display_options:
      title: 'Latest News'
      fields:
        field_preview_image:
          id: field_preview_image
          table: node__field_preview_image
          field: field_preview_image
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            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: target_id
          type: responsive_image
          settings:
            responsive_image_style: teaser_images
            image_link: ''
            image_loading:
              attribute: eager
          group_column: ''
          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
        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: true
          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
        field_full_name:
          id: field_full_name
          table: node__field_full_name
          field: field_full_name
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            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: false
          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
        field_article_excerpt:
          id: field_article_excerpt
          table: node__field_article_excerpt
          field: field_article_excerpt
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            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: false
          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
        field_description:
          id: field_description
          table: node__field_description
          field: field_description
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            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: basic_string
          settings: {  }
          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
        field_news_source:
          id: field_news_source
          table: node__field_news_source
          field: field_news_source
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            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: false
          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: infinite_scroll
        options:
          offset: 0
          items_per_page: 6
          total_pages: null
          id: 0
          tags:
            next: 'Next β€Ί'
            previous: 'β€Ή 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
          views_infinite_scroll:
            button_text: 'Load More'
            automatically_load_content: true
      exposed_form:
        type: bef
        options:
          submit_button: Apply
          reset_button: true
          reset_button_label: 'Clear all filters'
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
          bef:
            general:
              autosubmit: false
              autosubmit_exclude_textfield: false
              autosubmit_hide: false
              input_required: false
              allow_secondary: false
              secondary_label: 'Advanced options'
            filter:
              title:
                plugin_id: default
                advanced:
                  sort_options: false
                  placeholder_text: ''
                  rewrite:
                    filter_rewrite_values: ''
                  collapsible: false
                  is_secondary: false
              created:
                plugin_id: bef_datepicker
                advanced:
                  sort_options: false
                  placeholder_text: ''
                  rewrite:
                    filter_rewrite_values: ''
                  collapsible: false
                  is_secondary: false
              field_topics_target_id:
                plugin_id: bef
                advanced:
                  sort_options: false
                  placeholder_text: ''
                  rewrite:
                    filter_rewrite_values: ''
                  collapsible: false
                  is_secondary: false
                select_all_none: false
                select_all_none_nested: false
      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: created
          exposed: false
          granularity: second
      arguments: {  }
      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: ''
            operator_limit_selection: false
            operator_list: {  }
        type:
          id: type
          table: node_field_data
          field: type
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: node
          entity_field: type
          plugin_id: bundle
          operator: in
          value:
            article: article
            external_headline: external_headline
            pdf_news: pdf_news
          group: 1
          exposed: false
          expose:
            operator_id: ''
            label: ''
            description: ''
            use_operator: false
            operator: ''
            operator_limit_selection: false
            operator_list: {  }
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
            reduce: false
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
        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
          operator: between
          value:
            min: ''
            max: ''
            value: ''
            type: date
          group: 1
          exposed: true
          expose:
            operator_id: created_op
            label: Date
            description: ''
            use_operator: false
            operator: created_op
            operator_limit_selection: false
            operator_list: {  }
            identifier: Date
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
              anonymous: '0'
              administrator: '0'
              editor: '0'
              events_manager: '0'
            min_placeholder: ''
            max_placeholder: ''
            placeholder: ''
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
        field_topics_target_id:
          id: field_topics_target_id
          table: node__field_topics
          field: field_topics_target_id
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: taxonomy_index_tid
          operator: or
          value: {  }
          group: 1
          exposed: true
          expose:
            operator_id: field_topics_target_id_op
            label: Topic
            description: ''
            use_operator: false
            operator: field_topics_target_id_op
            operator_limit_selection: false
            operator_list: {  }
            identifier: field_topics_target_id
            required: false
            remember: false
            multiple: true
            remember_roles:
              authenticated: authenticated
              anonymous: '0'
              administrator: '0'
            reduce: false
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
          reduce_duplicates: true
          vid: topics
          type: select
          hierarchy: false
          limit: true
          error_message: true
        field_article_type_value:
          id: field_article_type_value
          table: node__field_article_type
          field: field_article_type_value
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: list_field
          operator: or
          value:
            news: news
          group: 1
          exposed: false
          expose:
            operator_id: ''
            label: ''
            description: ''
            use_operator: false
            operator: ''
            operator_limit_selection: false
            operator_list: {  }
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
            reduce: false
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
          reduce_duplicates: false
        field_full_node_value:
          id: field_full_node_value
          table: node__field_full_node
          field: field_full_node_value
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: string
          operator: allwords
          value: ''
          group: 1
          exposed: true
          expose:
            operator_id: field_full_node_value_op
            label: 'Search News'
            description: ''
            use_operator: false
            operator: field_full_node_value_op
            operator_limit_selection: false
            operator_list: {  }
            identifier: field_full_node_value
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
              anonymous: '0'
              administrator: '0'
            placeholder: ''
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
      filter_groups:
        operator: AND
        groups:
          1: AND
      style:
        type: default
      row:
        type: 'entity:node'
        options:
          relationship: none
          view_mode: teaser
      query:
        type: views_query
        options:
          query_comment: ''
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_tags: {  }
      relationships: {  }
      use_ajax: true
      header: {  }
      footer: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - url.query_args
        - user
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_article_excerpt'
        - 'config:field.storage.node.field_description'
        - 'config:field.storage.node.field_full_name'
        - 'config:field.storage.node.field_news_source'
        - 'config:field.storage.node.field_preview_image'
  listing:
    id: listing
    display_title: Listing
    display_plugin: block
    position: 1
    display_options:
      empty:
        area:
          id: area
          table: views
          field: area
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: text
          empty: true
          content:
            value: '<p class="no-results-msg">[removed for privacy]</p>'
            format: full_html
          tokenize: false
      defaults:
        empty: false
        css_class: false
        fields: true
        filters: true
        filter_groups: true
      css_class: news-listing--view
      display_description: ''
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - url.query_args
        - user
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_article_excerpt'
        - 'config:field.storage.node.field_description'
        - 'config:field.storage.node.field_full_name'
        - 'config:field.storage.node.field_news_source'
        - 'config:field.storage.node.field_preview_image'

If I have to, I suppose I can write a hook to force the view to use the old query, but that's obviously not a great solution. Maybe a patch is available to repair this logic?

Thanks.

πŸ› Bug report
Status

Closed: works as designed

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mefron

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

Comments & Activities

  • Issue created by @mefron
  • πŸ‡ΊπŸ‡ΈUnited States mefron

    Sorry, everyone. I just realized that the original builders of the site have some custom code that is complicating the behavior of this view. I assume that this is responsible for the problem, and so am going to close this topic.

    Apologies for the overquick post.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mefron
Production build 0.71.5 2024