Views "Is not one of" filter doesn't filter well

Created on 10 October 2019, about 5 years ago
Updated 7 April 2023, over 1 year ago

Using the "Is not one of" operation on a moderation workflow field filters out only the content types that don't have moderation enabled.

Example:
value1
value2
value3
value4
value5
value6

If I select "Is not one of" value3 and value5
I get:
value1
value2
value3
value4
value5
value6

I expect:
value1
value2
value4
value6

The problem is here:

    // The values are strings composed from the workflow ID and the state ID, so
    // we need to create a complex WHERE condition.
    $field = new Condition('OR');
    foreach ((array) $this->value as $value) {
      list($workflow_id, $state_id) = explode('-', $value, 2);

      $and = new Condition('AND');
      $and
        ->condition("$this->tableAlias.workflow", $workflow_id, '=')
        ->condition("$this->tableAlias.$this->realField", $state_id, $operator);

      $field->condition($and);
    }

    $this->query->addWhere($this->options['group'], $field);

The whole $field (as a group) should be negated instead of negating the second and condition in the cycle.

🐛 Bug report
Status

Needs work

Version

9.5

Component
Content moderation 

Last updated 24 days ago

Created by

🇧🇪Belgium golddragon007

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.

Production build 0.71.5 2024