Problem/Motivation

When taxonomy terms were converted to be revisionable in #2880149: Convert taxonomy terms to be revisionable we disabled Content Moderation integration because the UI was not ready yet.

Proposed resolution

After #2899923: UI for publishing/unpublishing taxonomy terms lands, we should re-enable CM integration.

Remaining tasks

None.

User interface changes

In a workflow's configuration screen (e.g editorial worklflow), users now have the option to apply the workflow to taxonomies.
Adding workflow to the tags vocabulary.

Once that's done the state field becomes available on the taxonomy term add and edit screens so users can moderate the vocabulary's taxonomy terms.
Taxonomy term edit screen with the content moderation state field.

API changes

Nope.

Data model changes

Nope.

Release notes snippet

Nope.

CommentFileSizeAuthor
#77 moderated-taxonomy-term.png74.01 KBpavlosdan
#77 add-workflow-to-tags.png28.73 KBpavlosdan
#68 3047110-nr-bot.txt90 bytesneeds-review-queue-bot
#66 3047110-nr-bot.txt2.37 KBneeds-review-queue-bot
#64 3047110-64-11.x.patch12.69 KBsakthi_dev
#58 stg_content-moderation_unpublish-state-error.gif6.29 MBmiserable_full-stack_developer
#56 link_to_moderated_content.png177.51 KBkreynen
#49 enable_content_moderation_for_terms-3047110-49.patch12.49 KBslydevil
#45 3047110-45.patch13.41 KBswirt
#32 interdiff_29-32.txt6.55 KBvsujeetkumar
#32 3047110-32.patch11.54 KBvsujeetkumar
#29 3047110-29.patch11.36 KBdhirendra.mishra
#29 interdiff_28-29.txt1.47 KBdhirendra.mishra
#28 3047110-28.patch11.37 KBhugronaphor
#27 3047110-27.patch2.91 KBhugronaphor
#18 3047110-18.patch11.01 KBManuel Garcia
#18 interdiff-3047110-16-18.txt9.7 KBManuel Garcia
#16 3047110-16.patch10.88 KBManuel Garcia
#9 3047110-8.patch10.8 KBn4r3n
#7 3047110-6.patch10.81 KBandypost
#3 3047110-do-not-test.patch10.8 KBamateescu

Issue fork drupal-3047110

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amateescu created an issue. See original summary.

amateescu’s picture

Status: Active » Needs work
FileSize
10.8 KB

Here's the initial work needed here. Not sending to the testbot since it needs #2899923: UI for publishing/unpublishing taxonomy terms first.

Manuel Garcia’s picture

Status: Needs work » Postponed
timmillwood’s picture

Status: Postponed » Needs review

Guess we can open this back up now.

Manuel Garcia’s picture

Blocking issue is in so yes. Triggered the tests on the initial patch just to see where we are with this.

andypost’s picture

FileSize
10.81 KB

reroll for taxonomy.module hunk

Status: Needs review » Needs work

The last submitted patch, 7: 3047110-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

n4r3n’s picture

yogeshmpawar’s picture

Status: Needs work » Needs review

Setting back to Needs Review & Triggering bots.
@n4r3n - can you please post the interdiff as well?

Manuel Garcia’s picture

Nits / CS review.

  1. +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermContentModerationTest.php
    @@ -0,0 +1,201 @@
    +    $parent_1 = $this->createTerm($this->vocabulary, ['langcode' => 'en', 'moderation_state' => 'published', 'parent' => $root->id()]);
    +    $parent_2 = $this->createTerm($this->vocabulary, ['langcode' => 'en', 'moderation_state' => 'published', 'parent' => $root->id()]);
    +    $parent_3 = $this->createTerm($this->vocabulary, ['langcode' => 'en', 'moderation_state' => 'published', 'parent' => $root->id()]);
    ...
    +    $child = $this->createTerm($this->vocabulary, ['langcode' => 'en', 'moderation_state' => 'published', 'parent' => $parent_1->id()]);
    

    These arrays should be one item in each line.

  2. +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermContentModerationTest.php
    @@ -0,0 +1,201 @@
    +    $this->assertSession()->pageTextNotContains($validation_message);
    ...
    +    $this->assertSession()->pageTextContains($validation_message);
    ...
    +    $this->assertSession()->pageTextContains($validation_message);
    ...
    +    $this->assertSession()->pageTextContains($validation_message);
    ...
    +    $this->assertSession()->pageTextContains($validation_message);
    ...
    +    //$this->assertSession()->pageTextNotContains($validation_message);
    ...
    +    $this->assertSession()->pageTextContains($validation_message);
    ...
    +    $this->assertSession()->pageTextNotContains($validation_message);
    ...
    +    $this->assertSession()->pageTextContains($default_term_name);
    +    $this->assertSession()->pageTextContains($default_term_description);
    ...
    +    $this->assertSession()->fieldNotExists('revision_log_message[0][value]');
    ...
    +    $this->assertSession()->pageTextContains($pending_term_name);
    +    $this->assertSession()->pageTextContains($pending_term_description);
    +    $this->assertSession()->pageTextNotContains($default_term_description);
    ...
    +    $this->assertSession()->pageTextContains($default_term_name);
    +    $this->assertSession()->pageTextContains($default_term_description);
    

    let's cache this as $assert_session = $this->assertSession();

Status: Needs review » Needs work

The last submitted patch, 9: 3047110-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Manuel Garcia’s picture

+++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermContentModerationTest.php
@@ -0,0 +1,201 @@
+    // Check that parents were changed.
...
+    $taxonomy_storage->resetCache();
+    $this->assertEquals([$parent_2->id()], array_keys($taxonomy_storage->loadParents($child->id())));

Since we're checking here that parents were changed, should we do assertNotEqual() instead?

Also, should we uncomment //$this->assertSession()->pageTextNotContains($validation_message); ?

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

t3kn0ph34r’s picture

With #2899923: UI for publishing/unpublishing taxonomy terms being closed, is this back under active consideration/development?

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
10.88 KB

Re #15 yes indeed, we are free to work on this now.

Latest patch #9 needed a reroll, so here's a first step forward.

Status: Needs review » Needs work

The last submitted patch, 16: 3047110-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
9.7 KB
11.01 KB

The failing test on #16 is because the test is trying to change the parent before publishing the taxonomy term, I have changed the test to first publish the term, then change the parent. Please let me know if this is not correct and the failure is valid and there is a bug, to me it seems reasonable but I could be wrong.

The rest of changes are essentially tidying things up and addressing my comments earlier on #11 and #13.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

amateescu’s picture

Status: Reviewed & tested by the community » Needs work

I think the failure from #16 is genuine, because it should be possible to change the parent of a term _at the same time_ when the term is being published.

The underlying problem is probably somewhere in Content Moderation, because $entity->isDefaultRevision() should return TRUE in an entity validator constraint, if the entity that is about to be saved *will be* a default revision.

Also found this small bug while looking into it :) #3134704: Remove stray debug leftover in TaxonomyTermHierarchyConstraintValidator

dmitry.korhov’s picture

Priority: Normal » Major

Tried patch with JSON:API export and it does not work.
$resource_type->isVersionable() returns false. So draft and published versions of terms are not exposed with JSON:API

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Artusamak’s picture

Surprisingly, #16 still works with 9.1.9!

Yet i'm wondering how to manage the content moderation view that is only applying to nodes. Though, it's probably out of this issue's scope.

Thanks!

greggmarshall’s picture

Composer reports patch #18 fails to apply on 9.2.0.

  - Applying patches for drupal/core
    https://www.drupal.org/files/issues/2020-04-17/3047110-18.patch (Enable Content Moderation integration for taxonomy terms)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-04-17/3047110-18.patch

Actually the best I can tell section of the patch modifying the taxonomy.module by deleting the .function taxonomy_entity_type_alter isn't needed any more since that bit of code seems to have been deleted in 9.2.0 in issue #3204883: Move exclusion of taxonomy terms from moderation to content_moderation module.

hugronaphor’s picture

FileSize
2.91 KB

Re-roll the patch while taking into account the changes in #3204883: Move exclusion of taxonomy terms from moderation to content_moderation module.

Content moderation still works with this

hugronaphor’s picture

FileSize
11.37 KB

Added missing TaxonomyTermContentModerationTest.php

dhirendra.mishra’s picture

Fixed the coding standards issue from previous patch..

dhirendra.mishra’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 29: 3047110-29.patch, failed testing. View results

vsujeetkumar’s picture

Status: Needs work » Needs review
FileSize
11.54 KB
6.55 KB

Fixed fail tests, It is related to:
- "drupalPostForm()" & "taxonomy_term_load_multiple_by_name()" are deprecated,
- "void return",
- "$modules" property must be declared protected.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kreynen’s picture

We've been testing this including building out Views as part of a custom moderation UI. Everything was working really well until we ran into #3145661: Users without "administer taxonomy" permission can't see unpublished terms canonical pages. Granting full access to administer taxonomy to users in the role we created to review new terms is problematic for us. In our use case, mistakenly deleting a term would cause a lot of problems.

We're evaluating the time involved in adding custom validation to prevent this, but Content Moderation of Taxonomy Terms still has limitations when compared to moderating Content Types.

kreynen’s picture

Another feature missing from really being able to leverage Content Moderation on Taxonomy is the Most Recent Revision filter in Views. That was rewritten in #2865579: Rewrite the 'Latest revision' views filter and remove the revision_tracker table. It's not clear to me what would need to be done to include support for that filter in the Taxonomy Revision Views, but it is difficult to leverage moderation state without it.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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.

jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

I've applied and tested patch from #32 on Drupal 9.5.2 and it works just great.

quietone’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

@jurgenhaas, thanks for reporting that the patch is working for you and the version of Drupal it is being used on.

The Issue Summary is clear.

Going through the comments I see that the following have not been addressed

  • #13 - The commented out line is still in the patch.
  • #21

I skimmed the patch and noticed the following items.

  1. +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php
    @@ -278,7 +282,7 @@ public function testContentModerationStateTranslationDataRemoval($entity_type_id
    +      $translation = $entity->addTranslation($langcode, [$entity->getEntityType()->getKey('label') => 'French title test']);
    

    This looks to be out of scope.

  2. +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermContentModerationTest.php
    @@ -0,0 +1,201 @@
    +    // Add a pending revision and change the parent.
    

    It would be easier to follow if parent_1 was used here. The same applies to other comments. As in 'change the parent to parent_2' and so on.

  3. +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermContentModerationTest.php
    @@ -0,0 +1,201 @@
    +    //$this->assertSession()->pageTextNotContains($validation_message);
    

    Why is this commented out?

I saw an @todo in the code for this issue. A search of core needs to be done to check for all instances and determine if the todo can be deleted.

jurgenhaas’s picture

Oh sorry for that @quietone - as the issue was NR I thought that all that had been addressed. Will be more cautious next time.

kreynen’s picture

I can't see how this could get merged without resolving #3145661: Users without "administer taxonomy" permission can't see unpublished terms canonical pages. The expectation of enabling Content Moderation on Taxonomy Terms is going to be that the responsibility could be assigned to the same roles as other types of content. Requiring Administer Taxonomy for this seems wrong.

Not sure if the lack of a View filter would get resolved here or in a follow-up issue, but this is another place where it won't work the way most people expect.

Rajeshreeputra made their first commit to this issue’s fork.

swirt’s picture

Posting a patch from the last MR push because I need an immutable patch.

Rajeshreeputra’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

From what I can tell points in #39 have not been addressed.

Which also mentions other comments not addressed.

slydevil made their first commit to this issue’s fork.

slydevil’s picture

Added permission check for view all revisions - @kreynen is correct.

slydevil’s picture

Rajeshreeputra’s picture

One thing noticed that once taxonomy term published and then moved to Draft, still the term is in published state.

Artusamak’s picture

It's the same behavior for nodes.

kreynen’s picture

Yep. The draft version is "ahead" of the currently published version until it is published.

slydevil’s picture

I chose the Node permission "view all revisions" and this is definitely wrong. The issue https://www.drupal.org/project/drupal/issues/2936995 provides revision permissions and should probably be a blocker for this issue.

kreynen’s picture

FileSize
177.51 KB

The current MR solved my original issue, but our use case is only using moderation on a single vocabulary. I agree with @slydevil that it makes more sense to use view terms revisions in $id, but then we just get to the next place where the experience of managing drafts of terms doesn't have feature parity with content.

I added #3359159: Add Status to OverviewTerms.php form and proposed a patch to add Status to the Terms Overview UI. Unlike the Content Overview, admin/structure/taxonomy/manage/[tid[/overview is not a View and there is no support to filter terms by moderation state making it hard to add the UI users are used to seeing in Content.

Link in Content UI users will expect in Taxonomy UI

I'm not sure if the goal is to make incremental progress on this in multiple issues or propose a single META MR that would provide the type of features users will expect to see when enabling moderation on a specific Vocabulary.

Version: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

miserable_full-stack_developer’s picture

We have a project using 9.3.2, Acquia_CMS 1.4.0.
We added node type and/or taxonomy to a workflow item.
We tried enable_content_moderation_for_terms-3047110-49.patch.
We're using 3047110-32.patch to enable moderation for taxonomy_term.
We contacted Acquia Support.
We are failing at UNPUBLISHING either node or taxonomy_term.

Is anyone experience this issue and how to fix it?

I'm thinking that the feature can do this:
- User can specify a state as published.
- When user set the state, the feature will set entity.status to 1.
I'm thinking that the feature CAN NOT do this at the moment:
- User no need to specify states as unpublished.
- When user set a state other than the state-as-published, the feature won't set entity.status to 0.

If someone can help I'm willing to share what more needed detail.
It's been 1/2 year already.
Thanks in advance!

PS:
We're trying to upgrading to D9.4.15 (PHP 7.4) and ACMS 1.5.5 with hope to get the issue resolved but facing many issues while updating DB and importing configs.
- Our Staging environment is blocked by unknown validation when saving content. It's READ-ONLY mode now.
- We got dirty configuration in database.
- We 're facing getConfigDependencyName() on NULL while updating DB by scheduler_content_moderation_integration_update_9002()

kreynen’s picture

Woot! #3359159: Add Status to OverviewTerms.php form was merged into core! Small step, but it improves the core UI when using this patch.

Manuel Garcia’s picture

Woot! #3359159: Add Status to OverviewTerms.php form was merged into core! Small step, but it improves the core UI when using this patch.

Hey thanks for that, a good improvement indeed!

Manuel Garcia’s picture

acbramley’s picture

Adding related revisions UI issue.

pavlosdan made their first commit to this issue’s fork.

sakthi_dev’s picture

FileSize
12.69 KB

Rerolled with 11.x.

pavlosdan’s picture

Status: Needs work » Needs review

Setting this back to needs review. The issues in #39, #47 seem to have been addressed except no1 in #39 which I don't think is out of scope since we need content moderation to be testing for taxonomy_term entity as well which may have a different entity key for label than other entities which may use "title".

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
2.37 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

@sakthi_dev please do not upload patches, this issue is using an MR and patches are confusing the bot.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley changed the visibility of the branch 3047110-enable-content-moderation-9.5.x to hidden.

acbramley’s picture

Oh! The MR is still against 10.x. We either need it rebased against 11.x, or it's probably easier to create a new branch off 11.x and apply the changes (which seem like they're not applying cleanly according to the bot)

I've hidden the 9.5.x branch

pavlosdan’s picture

Status: Needs work » Needs review

Created a new branch from 11.x and cherrypicked the commits onto it.

acbramley changed the visibility of the branch 3047110-enable-content-moderation to hidden.

acbramley’s picture

Status: Needs review » Needs work

We're missing a moderation handler here too, see BlockContentModerationHandler

pavlosdan’s picture

Status: Needs work » Needs review
acbramley’s picture

Great work on the MR, I think now we just need an IS update and a CR.

pavlosdan’s picture

Change record added https://www.drupal.org/node/3424780 and issue summary updated.

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

Great job @pavlosdan, thank you for pushing this along - the only thing for me now is whether we have enough test coverage or not. CM is a huge layer of complexity, but the test coverage in the MR (along with existing test coverage that we're enabling for taxonomy terms) seems quite thorough.

I think we're good to go!

pavlosdan’s picture

Thank you for the reviews and suggestions @acbramley!

  • longwave committed 2d61a0ef on 10.3.x
    Issue #3047110 by pavlosdan, Rajeshreeputra, Manuel Garcia, slydevil,...

  • longwave committed 07473ef2 on 11.x
    Issue #3047110 by pavlosdan, Rajeshreeputra, Manuel Garcia, slydevil,...
longwave’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: +10.3.0 release highlights

I think the test coverage is fine; the actual changes here are minimal and this functionality is already tested, we just need to ensure it's extended for this entity type which has been done here.

Committed and pushed 07473ef250 to 11.x and 2d61a0ef34 to 10.3.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.