Problem/Motivation

When disabling moderation on a bundle all ContentModerationState entities are left intact.

Proposed resolution

Give the user the option to remove all ContentModerationState entities for the given bundle (or not).

Remaining tasks

User interface changes

API changes

Data model changes

Comments

timmillwood created an issue. See original summary.

cilefen’s picture

Title: When disabling moderation there is now way to remove moderation states » When disabling moderation there is no way to remove moderation states
sam152’s picture

Status: Active » Needs review
StatusFileSize
new55.16 KB
new3.91 KB

Button that only appears after moderation is enabled and the user tries to disable it.

Here is an early patch. Since we don't have a concrete entity reference field to the associated entity we can't write queries that include the bundle. There was some unholy approach I could see that involved a hook query alter, but the easiest approach seemed to be to store the bundle as well.

Before going any further and writing tests and an upgrade path we should probably discuss/agree on:

  • If storing the bundle is something we want to do.
  • What the UI should look like, strings, buttons, messages.
timmillwood’s picture

Issue tags: +Needs usability review
Bojhan’s picture

Issue tags: -Needs usability review

This is not reviewable. Can this get a less technical explanation?

Most of what I see in the screenshot would be a HIG violation, so I would recommend to start with identifying the different ways this could be solved, rather than already converging to the one solution.

timmillwood’s picture

@Bojhan - When creating or updating a moderated entity we create a ContentModerationState entity to store the moderation state for the content. If the site builder disables moderation these ContentModerationState entities don't get deleted, they are just left in the database. From a UX point of view, what should we be doing with this data?

IMHO as @Sam152's patch shows I think we should have the option to delete this data, but I think wording is important, because this is hidden (meta like) data.

Also the "Delete" link shown in the screenshot shouldn't be there, #2818267: Remove delete link from Manage moderation settings page is working to resolve this.

Maybe the grey button shown in the screenshot should be a red link? Because it's a destructive action. Then does it need a confirmation form?

sam152’s picture

Most of what I see in the screenshot would be a HIG violation

For those of us who don't know much about this, can you elaborate on what aspects are wrong? I think the convergence is based on there being a limited number of places or options this feature could slot in.

I think useful feedback would be:

  • The use of a button vs some kind of appearing checkbox or toggle
  • The visual style of the button (as Tim pointed out)
  • The label of the button

I like the idea to make the button red.

Bojhan’s picture

Issue tags: +Needs usability review
Daniel Kanchev’s picture

Hi everyone :) I read the description of the problem and all the comments and I would like to ask the following questions:

1. @Bojhan is there an existing Human Interface guidelines Drupal document which I can find somewhere and read it? If there is such a document is everything in it obligatory or is the information in it just supposed to guide people?

2. @timmillwood and @Sam152 - in your case you wanted to delete all ContentModerationState entities for the given bundle and that is why you added the button in question. However, is this the only action which should be offered to the user? In other words I would like to suggest that some users may want to directly change the state of content to "published" and not delete it. Or are you deleting only the states and not the content itself which was set to be in one of these states? Also if only the states are deleted what will happen to content which was set to any of the states - to me personally this is not clear. Probably I am not able to understand the whole picture.

timmillwood’s picture

Status: Needs review » Needs work

@Daniel Kanchev - I think we should provide two options, just "save" and "save and delete moderation states". Deleting moderation states will just delete all ContentModerationState entities for that bundle.

The patch #3 adds the bundle id to the ContentModerationState, therefore it will only work for ContentModerationState entities created after this update. Maybe we'd be better running an entity query to get the entity IDs we wish to delete.

We shouldn't need to change the published state of anything.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

yoroy’s picture

When disabling moderation on a bundle all ContentModerationState entities are left intact

For whom is this a problem in the first place? I don't think content editors would care, or is there a scenario where this could bite them sometime later?

Do site builders care? How does not deleting the moderation state entities impact their work?

Do developers care? Probably yes or this issue wouldn't exist :-). Do they need a UI for this?

To me it seems super technical to first make people understand that actually, the moderation state your content was in is stored in separate thingies that are now unused and do you want to delete them? “I don't know!” :-)

Lets first establish if, and if so, why, we need to make this a task for the user to make a decision about.

timmillwood’s picture

Content editors should care, but maybe not enough to select between two options.

The UI of this has changed in 8.3.x and may change further with #2843083: Select entity type / bundle in workflow settings, but we still need to know what to do with the data.

Maybe we just decide, much like when you uninstall a module all data relating to that module is deleted, then you remove an entity type from moderation all data relating to that entity type for moderation is deleted?

yoroy’s picture

*Why* should content editors care though? :)

My initial assumption was indeed that it could work similar to uninstalling modules. You lose the settings related to moderation because you disabled it. But there is a difference between uninstalling and disabling. I'm trying to find out if there's a reasonable scenario where you'd expect your moderation settings to magically reappear when you turn moderation on again.

timmillwood’s picture

If we remove moderation states when disabling moderation the following scenario would happen:
You set node/1 to state "Needs review" then disable moderation for nodes, then enable it again, node/1 will get the state "default"

Currently enabling moderation again you'd get the "Needs review" state back for node/1.

Uninstalling Content Moderation removes all states from all entity types.

eaton’s picture

This seems similar to the "Deleting an Image Style" scenario. In that case, we allow admins to select a replacement image style and shift any references to the replacement. This is a bit different, but letting admins choose which states should map to "Published" and which ones should map to "Published" seems like the best approach to avoid accidents.

timmillwood’s picture

Status: Needs work » Needs review

This issue relates specifically to disabling moderation on a bundle, not removing a state, so no mapping needs to be done.

In #2817835: When enabling moderation apply a relative state we're looking to return relevant states, and in #2867312: Create a batch process to ensure entities that exist for newly moderated entity types get a corresponding ContentModerationState entity, so that views works. we're actually looking to store this data. So the issue I outlined in #15 will be less of an issue.

I wonder if there's any concern around just leaving the moderation data there?

yoroy’s picture

Version: 8.3.x-dev » 8.4.x-dev

From an editor’s perspective I don't think there’s a problem with leaving it around. I assume it’s mostly about programmatically cleaning up after ourselves? But it seems like there’s value in keeping these around.

timmillwood’s picture

Status: Needs review » Closed (works as designed)

@yoroy - sounds fine to me.

Lets just leave them there.

chartmann’s picture

Doesn't anyone else have the issue of View related duplicates after uninstalling Workbench moderation on a multilingual site? I've already dealt with using language filters to deal with multilingual duplicates, and it now seems the only duplicates that are showing up, are those with no revision information.

rick_p’s picture

I want to upgrade core beyond 8.2.7 on a production site, but Content Moderation must be disabled first. https://www.drupal.org/node/2869631

Content Moderation cannot be disabled until the states of all nodes are removed (There is content for the entity type: Content moderation state. Remove content moderation states) but the link to remove Content moderation state returns an error (The website encountered an unexpected error. Please try again later.).

Losing all the states, or having them all default to published is rather problematic but it is what it is, I guess we'll have to do a lot of preparation if we want to restore things manually later.

I found the following thread that has a patch to assist with uninstalling the content moderation module. Is the the only way to get past the issue so that I can upgrade core? https://www.drupal.org/project/workbench_moderation/issues/2627012

Any assistance greatly appreciated. Rick

vincenzo gambino’s picture

Hi all,

Recently I have tried to remove an early created workflow. The workflow type hasn't got any entity type assigned to it now but it was assigned to some content types in the past and some content is using it.
When I tried to delete the workflow type, I got the message "This workflow is in use. You cannot remove this workflow until you have removed all content using it."
I don't want to delete the content as the content type is assigned to a new Workflow.
To do that, I have created an update script similar to the one in the current patch where it deletes all the content_moderation_state entries for a particular Workflow type.

/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
  $entity_type_manager = \Drupal::service('entity_type.manager');
  $content_moderation_storage = $entity_type_manager->getStorage('content_moderation_state');
  foreach($workflows as $workflow) {
    // Load all the content moderation of a workflow type.
    $results = $content_moderation_storage->loadByProperties(['workflow' => $workflow]);
    /** @var \Drupal\content_moderation\ContentModerationState $result */
    // Delete the content moderation entity.
    foreach ($results as $result) {
      $result->delete();
    }
  }

Now I can delete the Workflow type.
Will this cause any issue to the site?

pavlosdan’s picture

Version: 8.4.x-dev » 9.3.x-dev
Status: Closed (works as designed) » Needs work

Re-opening this because it seems that the stale workflow entities left on the content type are causing issues. Namely, the workflow cannot be deleted and gives the message:

"This workflow is in use. You cannot remove this workflow until you have removed all content using it."

This also breaks configuration management as the config import will fail with the same message as above when it attempts to delete the workflow on the site that had it before but can't.

ravi.shankar’s picture

StatusFileSize
new3.64 KB
new3.91 KB

Here I have tried to add reroll of patch #2 on Drupal 9.3.x.

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new3.64 KB
new1.23 KB

Resolved CSpell errors

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Category: Task » Feature request
Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.

This seems more like a feature request and will need a test case for it

Thanks.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ravi.shankar’s picture

StatusFileSize
new3.63 KB
new963 bytes

Fixed Drupal CS issue of patch #25, still needs work for comment #26,

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.