Problem/Motivation

I would like to use the entity reference filter with the "is not one of" setup.
I receive an AJAX error on the views edit interface.
In the error log i see this message:
Error: Attempt to assign property "type" on null in Drupal\views\ManyToOneHelper->ensureMyTable() (line 254 of /.../web/core/modules/views/src/ManyToOneHelper.php).

Steps to reproduce

The entity reference filter works correctly if the filter is "is one of".
I use Drupal 11.

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:

Comments

marksmith created an issue. See original summary.

maximkashuba’s picture

Version: 2.0.0-beta5 » 2.0.x-dev
Component: Documentation » Code
Category: Support request » Bug report

Thanks for reporting this, and sorry for the late reply! I can confirm the bug. It still happens in the current 2.0.x.

Steps to reproduce
1. Create a Content view.
2. Add the filter "Content: ID (entityreference filter)" or "Authored by (entityreference filter)".
3. Set the operator to "Is none of" (or "Is all of").
4. Preview the view. It fails with Attempt to assign property "type" on null in ManyToOneHelper->ensureMyTable().

The same operators work fine on reference field columns (node__field_*).

Cause
The filter extends core's ManyToOne, which assumes the filtered column lives in a separate (multi-value) table that has to be joined. For the "Is none of" and "Is all of" operators, ManyToOneHelper::ensureMyTable() always gets that join and sets its type.
When the column is on the view's base table (entity id columns like nid, or base fields like uid), there is no join:
getJoin() returns NULL and the query build fails. "Is one of" works only because core has a NULL check for that case.

I'm moving this to a bug report against 2.0.x-dev. A fix with test coverage will follow.

  • maximkashuba committed 1336664a on 2.0.x
    Issue #3508437: Fix PHPCS long array lines in BaseTableOperatorsTest
    

  • maximkashuba committed 41b30146 on 2.0.x
    Issue #3508437: Keep node_modules out of the composer job artifact
    
    The...

  • maximkashuba committed d2a14542 on 2.0.x
    Issue #3508437: Fix the "is none of" and "is all of" operators on base...
maximkashuba’s picture

Status: Active » Fixed

Fixed in MR !31 and released in 2.0.0-beta9.

"Is none of" and "Is all of" now work when the filter is on an entity ID
column (base table or via a relationship). Field columns keep the
existing ManyToOne behaviour. Kernel test coverage added for both cases.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.