'not in' operator for the ModerationStateFilter uses the wrong conjunction

Created on 7 December 2019, about 5 years ago
Updated 27 April 2023, over 1 year ago

Problem/Motivation

The 'not in' operator of the ModerationStateFilter uses an OR conjunction, so when more than one filter value is selected, the query reads 'not in VALUE1 OR not in VALUE2'. Since the moderation_state only has a single value, it's bound not to be in one of those, so the condition returns FALSE for all entities.

Proposed resolution

The 'not in' operator should use the 'AND' conjunction.

🐛 Bug report
Status

Needs work

Version

10.1

Component
Content moderation 

Last updated 24 days ago

Created by

🇺🇸United States jantoine

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.

  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Try To Fix the Custom CMD Failed Patch #11.
    Add the Interdiff For the 11-13 patch.

  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Fix the Failed Patch.

  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    #6 has not been addressed.

  • 🇫🇮Finland heikkiy Oulu

    I encountered the same issue. We have two moderation states: Trashed and Archived.

    I wanted to filter out content from a custom view with both moderation states but it was impossible.

    This patch seems to fix the issue in the core Moderated content view but I can still see the issue in a custom view using the Moderation state filter.

    The patch seems to change the filter correctly like this:

    SELECT "node_field_data"."langcode" AS "node_field_data_langcode", "node_field_revision"."changed" AS "node_field_revision_changed", "node_field_data"."nid" AS "nid"
    FROM
    {node_field_data} "node_field_data"
    INNER JOIN {node_field_revision} "node_field_revision" ON node_field_data.vid = node_field_revision.vid
    LEFT JOIN {content_moderation_state_field_revision} "content_moderation_state" ON node_field_revision.vid = content_moderation_state.content_entity_revision_id AND (content_moderation_state.content_entity_type_id = 'node' AND content_moderation_state.content_entity_id = node_field_revision.nid AND content_moderation_state.langcode = node_field_revision.langcode)
    INNER JOIN {node} "node" ON node_field_revision.nid = node.nid
    WHERE ("node"."type" IN ('article', 'blog', 'collection', 'education_training', 'event', 'external_app', 'page', 'person', 'project', 'research_group', 'subsite', 'thesis', 'webform', 'weblink')) AND (("content_moderation_state"."workflow" = 'default') AND ("content_moderation_state"."moderation_state" NOT IN ('trashed', 'archived')))
    ORDER BY "node_field_revision_changed" DESC
    LIMIT 10 OFFSET 0
    

    But it does not yet filter out the content correctly based on the moderation state if multiple values are selected.

Production build 0.71.5 2024