Attempting to unpublish a moderated node produces an error message

Created on 6 May 2021, over 3 years ago
Updated 14 February 2023, almost 2 years ago

Problem/Motivation

Attempting to publish a moderated node from the Content Admin page produces this warning:

> Warning message
> Culture Of Light content items were skipped as they are under moderation and may not be directly unpublished.

which is fine, but also this error:

> Error message
> No access to execute Unpublish content on the Content Translation revision test - published state - unpublished ticky.

which is shouldn't be there.

Steps to reproduce

Set up content moderation on a node type.
Create a node of this type.
Try to unpublish it from admin/content

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

9.5

Component
Content moderation 

Last updated 24 days ago

Created by

🇬🇧United Kingdom joachim

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.

  • 🇭🇷Croatia Aporie

    I came along the same issue, and it's not just when trying to use mass_update of nodes from the admin action under /admin/content. It's a global core issue which doesn't take into account moderation state when trying to perform the "unpublish" action.

    By default, the $node->setUnpublish() only set node status to FALSE which is prevented by content moderation which requires $node->set('moderation_status', 'whatever_is_your_status'). And the trouble starts here, knowing that you can customize all workflows and states, identifying the one which will archive (unpublish) the node ... it might require a bit of digging around to fix this.

    Just brainstorming a possible approach, everywhere an action to unpublish a node is taken we should check for:
    - if content_moderation is activated.
    - identify which state is used for unpublishing (if there is one).
    - check for user access against this transition
    - if all green: $node->setUnpublish(); $node->set('moderation_state', UNPUBLISH_STATE); $node->save();

    It's just a wild guess I didn't have the time to investigate more. On my side I overtook the cancelComfirm function on a custom route and perform user_cancel($edit, $user->id(), 'user_cancel_block'); + my custom batch implementations (which take care of content_moderation integration).

  • Status changed to Closed: duplicate about 1 month ago
Production build 0.71.5 2024