taxonomy exposed filter error - Attempt to assign property "extra" on null in Drupal\views\ManyToOneHelper->ensureMyTable() (line 205 of /var/www/html/web/core/modules/views/src/ManyToOneHelper.php)

Created on 30 June 2022, about 2 years ago
Updated 24 September 2023, about 1 year ago

Problem/Motivation

In some configurations the views data seems to be insufficient which causes the Taxonomy term filter for views to try to taxonomy_term_field_data to itself. However, this is not a defined join in the views data which causes the reported error Attempt to assign property "extra" on null in Drupal\views\ManyToOneHelper->ensureMyTable() (line 205 of /var/www/html/web/core/modules/views/src/ManyToOneHelper.php) (see original report for the full stack trace).

Steps to reproduce

  1. Install Drupal
  2. Create a new taxonomy vocabulary
  3. Create a custom content entity
    1. using Drupal\views\EntityViewsData as view data handler
    2. Ensure the entity does not have bundles.
    3. In the base field definition provide an entity_reference field to the taxonomy
  4. Create a view with a page
    1. Add the taxonomy term as relationship
    2. Add an exposed filter for the taxonomy term, widget does not matter
  5. Create at least one custom entity
  6. Create at least one taxonomy term in the created vocabulary
  7. Attempt to search using the exposed taxonomy term

Proposed resolution

Remaining tasks

  • Validate reproduction steps

User interface changes

API changes

Data model changes

Release notes snippet

Original report

Hi i came across views filter wsod and I dont know why.

I am migrating drupal 7 to 9 commerce.
After UI migration I created a view of all the products from our store.
I created relationships with taxonomy terms which are (rings, earrings, bracelets)

When I created a dropdown filter list to select the specific term and filter the products by that term. I get wsod immediately.

I also created other filters for other taxonomy terms like the type of stones the jewelry has. I used exactly the same steps and it works with no problem.

Also exposed filter for published, unpublished products work.

So when I select dropdown for the specific term for taxomomy rings, earrings, bracelets I get this error in watchdog

Error: Attempt to assign property "extra" on null in Drupal\views\ManyToOneHelper->ensureMyTable() (line 205 of /var/www/html/web/core/modules/views/src/ManyToOneHelper.php)
#0 /var/www/html/web/core/modules/views/src/Plugin/views/filter/ManyToOne.php(123): Drupal\views\ManyToOneHelper->ensureMyTable()
#1 /var/www/html/web/core/modules/views/src/ManyToOneHelper.php(262): Drupal\views\Plugin\views\filter\ManyToOne->ensureMyTable()
#2 /var/www/html/web/core/modules/views/src/Plugin/views/filter/ManyToOne.php(136): Drupal\views\ManyToOneHelper->addFilter()
#3 /var/www/html/web/core/modules/views/src/Plugin/views/filter/InOperator.php(390): Drupal\views\Plugin\views\filter\ManyToOne->opHelper()
#4 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1373): Drupal\views\Plugin\views\filter\InOperator->query(false)
#5 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1262): Drupal\views\ViewExecutable->_build('filter')
#6 /var/www/html/web/core/modules/views/src/Plugin/views/display/PathPluginBase.php(392): Drupal\views\ViewExecutable->build()
#7 /var/www/html/web/core/modules/views/src/Plugin/views/display/Page.php(196): Drupal\views\Plugin\views\display\PathPluginBase->execute()
#8 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1630): Drupal\views\Plugin\views\display\Page->execute()
#9 /var/www/html/web/core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay('page_1', Array)
#10 [internal function]: Drupal\views\Element\View::preRenderViewElement(Array)
#11 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#12 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(772): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#13 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(363): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#14 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(201): Drupal\Core\Render\Renderer->doRender(Array, false)
#15 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(241): Drupal\Core\Render\Renderer->render(Array, false)
#16 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#17 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#18 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#19 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#20 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#21 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#22 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(163): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#23 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#33 {main}

thank you for looking into it. I can provide additional info if needed.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡ΈπŸ‡ͺSweden rossidrup

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΊπŸ‡ΈUnited States cecrs

    Just leaving this here in case someone else runs into this for the same reason I did - I had a view with multiple exposed Term filters, and multiple relationships to the vocabularies. The Term filters were using the wrong relationship and that produced this error. I.e., view misconfiguration.

  • Status changed to Active about 1 year ago
  • πŸ‡³πŸ‡±Netherlands kingdutch

    I'm running into this same issue. I've updated the issue summary according to the template and adding what I believe are the reproduction steps (but unfortunately getting this set-up in a fully clean install is more work than I have time for tonight, so I have a few changes in my custom set-up).

    My custom entity definition and field definition are listed below, in case I've missed part of the reproduction steps. My entity annotation is using the entity module's ViewsData provider, but I swapped the core one out and could still reproduce the issue (hence mentioning the core class in the IS).

    The entity annotation.

    /**
     * Define transactions that occur.
     *
     * @ContentEntityType(
     *   id = "bank_transaction",
     *   label = @Translation("Transaction"),
     *   label_collection = @Translation("Transactions"),
     *   label_singular = @Translation("transaction"),
     *   label_plural = @Translation("transactions"),
     *   label_count = @PluralTranslation(
     *     singular = "@count transaction",
     *     plural = "@count transactions"
     *   ),
     *   handlers = {
     *     "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage",
     *     "storage_schema" = "Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema",
     *     "permission_provider" = "Drupal\entity\EntityPermissionProvider",
     *     "access" = "Drupal\entity\EntityAccessControlHandler",
     *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
     *     "views_data" = "Drupal\entity\EntityViewsData",
     *   },
     *   admin_permission = "administer transactions",
     *   base_table = "bank_transaction",
     *   show_revision_ui = FALSE,
     *   translatable = FALSE,
     *   entity_keys = {
     *     "id" = "tid",
     *     "uuid" = "uuid",
     *   },
     *   links = {
     *     "canonical" = "/transactions/{account}",
     *     "collection" = "/transactions",
     *   },
     *   common_reference_target = TRUE,
     * )
     */
    class BankTransaction extends ContentEntityBase implements ContentEntityInterface {
    
    

    The taxonomy field definition in baseFieldDefinitions

        $fields['category'] = BaseFieldDefinition::create("entity_reference")
          ->setLabel(t('Category'))
          ->setDescription(t('The category this belongs to (e.g. Car > Fuel).'))
          ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
          ->setSetting('target_type', 'taxonomy_term')
          ->setSetting('handler', 'default:taxonomy_term')
          ->setSetting('handler_settings', [
            'target_bundles' => [
              'bank_transaction_category' => 'bank_transaction_category',
            ],
          ]);
    

    The views filter definition YML:

            tid:
              id: tid
              table: taxonomy_term_field_data
              field: tid
              relationship: category_target_id
              group_type: group
              admin_label: ''
              entity_type: taxonomy_term
              entity_field: tid
              plugin_id: taxonomy_index_tid
              operator: and
              value: {  }
              group: 1
              exposed: true
              expose:
                operator_id: tid_op
                label: Category
                description: ''
                use_operator: false
                operator: tid_op
                operator_limit_selection: false
                operator_list: {  }
                identifier: category
                required: false
                remember: false
                multiple: true
                remember_roles:
                  authenticated: authenticated
                  anonymous: '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: false
              vid: bank_transaction_category
              type: select
              hierarchy: true
              limit: true
              error_message: true
    

    The relationship definition

            category_target_id:
              id: category_target_id
              table: bank_transaction__category
              field: category_target_id
              relationship: none
              group_type: group
              admin_label: 'Taxonomy term'
              entity_type: bank_transaction
              entity_field: category
              plugin_id: standard
              required: false
    
  • πŸ‡³πŸ‡±Netherlands kingdutch

    This sounds a whole lot like #2642132: Error when using views contextual filters summary option on taxonomy term name β†’ and #2642132-15: Error when using views contextual filters summary option on taxonomy term name β†’ notes that the error is different depending on your PHP version and how it handles unexpected NULL types.

  • πŸ‡³πŸ‡±Netherlands kingdutch

    Apologies for the double posting, more searching found more results.

    #2829178-27: Views Term ID has broken filters ("All of", "Is none of") and contextual filters "allow multiple" β†’ mentions that there are specific filter configurations that cause problems and others that don't. Upon trying this locally I can say that for my local set-up "'Any of' work[s] but 'None of' and 'All of' do[es]n't work"

    That issue also has more work towards a patch done. I'm not entirely sure we should close this as duplicate since the ways to reproduce seem dissimilar but I have a hunch that the root cause is the same, just showing up in different ways.

Production build 0.71.5 2024