Error when using views contextual filters summary option on taxonomy term name

Created on 30 December 2015, about 9 years ago
Updated 27 January 2025, 8 days ago

Error message:

Recoverable fatal error: Argument 3 passed to Drupal\views\Plugin\views\query\Sql::ensureTable() must be an instance of Drupal\views\Plugin\views\join\JoinPluginBase, instance of stdClass given, called in /core/modules/views/src/ManyToOneHelper.php on line 137 and defined in Drupal\views\Plugin\views\query\Sql->ensureTable() (line 495 of core/modules/views/src/Plugin/views/query/Sql.php).

Warning: Creating default object from empty value in Drupal\views\ManyToOneHelper->summaryJoin() (line 133 of core/modules/views/src/ManyToOneHelper.php).
Drupal\views\ManyToOneHelper->summaryJoin()
Drupal\views\Plugin\views\argument\StringArgument->summaryQuery()
Drupal\views\Plugin\views\argument\ArgumentPluginBase->defaultSummary()
Drupal\views\Plugin\views\argument\ArgumentPluginBase->defaultAction()
Drupal\views\ViewExecutable->_buildArguments()
Drupal\views\ViewExecutable->build('industry_attachment')
Drupal\views\ViewExecutable->execute('industry_attachment')
Drupal\views\ViewExecutable->render('industry_attachment')
Drupal\views\Plugin\views\display\Attachment->execute()
Drupal\views\ViewExecutable->executeDisplay('industry_attachment', Array)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_eb8cb6b35fbdde3b0b8b1f5b01c2c24054f6cb1868e0d4f990a6cccbfb5ec266->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('core/themes/stable/templates/views/views-view.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render(Array, Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array, )
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

To recreate:

  • Create a vocabulary with the machine name 'industry'.
  • Create a content type called 'work' with a taxonomy term reference field called 'field_industry' that references the vocabulary and allows multiple values.
  • Create a page view displaying teasers of that content type with a relationship on field_industry + a contextual filter for taxonomy term name that uses that relationship.
  • Create an associated attachment view that attempts to use the 'summary' option on taxonomy term name and check 'Do not display items with no value in summary.'

I've included an export of the view that causes the error below. I was attempting to create an exposed attachment of term links to "filter" the page view by taxonomy term. Initially I did this without the relationship, but the taxonomy term field as a contextual filter displays term ID instead of term name (which was also unexpected).

Mac OSX, PHP 5.5.10

Export:

uuid: 306a6aad-95db-481f-8c09-09cb7617a45f
langcode: en
status: true
dependencies:
  config:
    - core.entity_view_mode.node.teaser
    - node.type.work
    - system.menu.main
  module:
    - node
    - taxonomy
    - user
id: work
label: Work
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: 0
    display_options:
      access:
        type: perm
        options:
          perm: 'access content'
      cache:
        type: tag
        options: {  }
      query:
        type: views_query
        options:
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_comment: ''
          query_tags: {  }
      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
      pager:
        type: none
        options:
          items_per_page: 0
          offset: 0
      style:
        type: grid
      row:
        type: 'entity:node'
        options:
          relationship: none
          view_mode: teaser
      fields:
        title:
          id: title
          table: node_field_data
          field: title
          entity_type: node
          entity_field: title
          label: ''
          alter:
            alter_text: false
            make_link: false
            absolute: false
            trim: false
            word_boundary: false
            ellipsis: false
            strip_tags: false
            html: false
          hide_empty: false
          empty_zero: false
          settings:
            link_to_entity: true
          plugin_id: field
          relationship: none
          group_type: group
          admin_label: ''
          exclude: 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_alter_empty: true
          click_sort_column: value
          type: string
          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
      filters:
        status:
          value: true
          table: node_field_data
          field: status
          plugin_id: boolean
          entity_type: node
          entity_field: status
          id: status
          expose:
            operator: ''
          group: 1
        type:
          id: type
          table: node_field_data
          field: type
          value:
            work: work
          entity_type: node
          entity_field: type
          plugin_id: bundle
      sorts:
        created:
          id: created
          table: node_field_data
          field: created
          order: DESC
          entity_type: node
          entity_field: created
          plugin_id: date
          relationship: none
          group_type: group
          admin_label: ''
          exposed: false
          expose:
            label: ''
          granularity: second
      title: 'Our Work'
      header: {  }
      footer: {  }
      empty: {  }
      relationships:
        field_industry:
          id: field_industry
          table: node__field_industry
          field: field_industry
          relationship: none
          group_type: group
          admin_label: 'field_industry: Taxonomy term'
          required: true
          plugin_id: standard
      arguments:
        name:
          id: name
          table: taxonomy_term_field_data
          field: name
          relationship: field_industry
          group_type: group
          admin_label: ''
          default_action: ignore
          exception:
            value: all
            title_enable: false
            title: All
          title_enable: false
          title: ''
          default_argument_type: fixed
          default_argument_options:
            argument: ''
          default_argument_skip_url: false
          summary_options:
            base_path: ''
            count: true
            items_per_page: 25
            override: false
          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: lower
          transform_dash: true
          break_phrase: false
          add_table: false
          require_value: true
          entity_type: taxonomy_term
          entity_field: name
          plugin_id: string
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - 'user.node_grants:view'
        - user.permissions
      tags: {  }
  industry_attachment:
    display_plugin: attachment
    id: industry_attachment
    display_title: Attachment
    position: 2
    display_options:
      display_extenders: {  }
      inherit_arguments: false
      displays:
        work_page: work_page
      defaults:
        arguments: false
      arguments:
        name:
          id: name
          table: taxonomy_term_field_data
          field: name
          relationship: field_industry
          group_type: group
          admin_label: ''
          default_action: summary
          exception:
            value: all
            title_enable: false
            title: All
          title_enable: false
          title: ''
          default_argument_type: fixed
          default_argument_options:
            argument: ''
          default_argument_skip_url: false
          summary_options:
            base_path: ''
            items_per_page: 25
            count: false
            override: false
          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: lower
          transform_dash: true
          break_phrase: false
          add_table: false
          require_value: true
          entity_type: taxonomy_term
          entity_field: name
          plugin_id: string
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - 'user.node_grants:view'
        - user.permissions
      tags: {  }
  work_page:
    display_plugin: page
    id: work_page
    display_title: Page
    position: 1
    display_options:
      display_extenders: {  }
      path: work
      menu:
        type: normal
        title: Work
        description: ''
        expanded: false
        parent: ''
        weight: 0
        context: '0'
        menu_name: main
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - 'user.node_grants:view'
        - user.permissions
      tags: {  }
🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component

views.module

Created by

🇺🇸United States jastraat

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇮Finland anaconda777

    I am getting

    Error: Attempt to assign property "type" on null in Drupal\views\ManyToOneHelper->ensureMyTable() (line 195 of /var/www/html/sitex/web/core/modules/views/src/ManyToOneHelper.php).

    This patch didnt fix this.
    I am getting it when a node has 2 taxonomy terms and trying to use them as contextua filter name in views.
    When accessing the URL /term1/term2 the site page crashs.

Production build 0.71.5 2024