Problem/Motivation

There are two use cases content moderation should support which involve blocks:

  • Moderating a reusable content blocks, through the normal content block creation screen.
  • Moderating a whole page which is a combination of various block types, with inline block content created and treated as a composite to the whole page.

Currently when you switch on content moderation for content blocks, moderation widgets and semantics kick in for both use cases, where they should be disabled for the latter.

Proposed resolution

Inline blocks created and inserted into a layout are referenced by their revision ID from the layout storage by design, so there is very little reason to create new revisions or alter the publishing status of an inline block created for layout builder. Content moderation should not get involved for inline blocks.

I believe a good implementation may be allowing the moderation entity handlers to have a say in things like the visibility of the widget, to forcefully opt-out of some aspects of content moderation. I believe you could already switch off creating new revisions or updating the publishing status.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sam152 created an issue. See original summary.

johnwebdev’s picture

+1 I think delegating if the entity is moderated to the Moderation handler is worth exploring.

Berdir’s picture

Makes sense, we already have a pseudo-official of opting out entirely by unsetting the moderation handler, terms and menu_link_content is doing that now in 8.7, but not yet dynamically based on some condition.

Sam152’s picture

Status: Active » Needs review
FileSize
3.04 KB

Making a start on this.

Sam152’s picture

Status: Needs review » Needs work
johnwebdev’s picture

Status: Needs work » Needs review
FileSize
3.07 KB
651 bytes

The entity type actually returns the handler as a string. This should do it.

johnwebdev’s picture

well, introducing whitespace doesn't, but this should :p

Status: Needs review » Needs work

The last submitted patch, 7: 3044292-7.patch, failed testing. View results

johnwebdev’s picture

Status: Needs work » Needs review
FileSize
4.62 KB
1.38 KB

Fixing last tests. Had to update the mocks.

Sam152’s picture

Interdiff from #4 since I rejigged the unit tests from that patch. Adding an integration test + the fix for inline blocks on moderated pages. By the looks of it, layout builder is the only way inline blocks are tested and used in core, so adding this to the CM/LB integration test seems to make the most sense to me.

Sam152’s picture

Category: Task » Bug report

Reclassifying as a bug, since it's pretty easy to configure this from modules that are advertised to work together.

Sam152’s picture

Issue tags: +Blocks-Layouts

Adding a tag in the hopes of attracting some eyeballs :)

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.

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

I've re-queued the test. Assuming it's still green, this looks good to me. The addition of the isModeratedEntity method to the handler is a great solution, and will provide flexibility in the future for other entity types that want more granular control of which entities are moderated.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs change record
+++ b/core/modules/content_moderation/src/ModerationInformation.php
@@ -52,8 +52,10 @@ public function isModeratedEntity(EntityInterface $entity) {
+    return  $this->entityTypeManager->getHandler($entity->getEntityTypeId(), 'moderation')->isModeratedEntity($entity);

nit two spaces here, can be fixed on commit

Tagging for needs change record, adding a new method to the interface is allowed under the 1:1 rule, as it is expected that implementations will extend from the base class.

Berdir’s picture

+++ b/core/modules/content_moderation/src/ModerationInformation.php
@@ -52,8 +52,10 @@ public function isModeratedEntity(EntityInterface $entity) {
     }
-
-    return $this->shouldModerateEntitiesOfBundle($entity->getEntityType(), $entity->bundle());
+    if (!$this->shouldModerateEntitiesOfBundle($entity->getEntityType(), $entity->bundle())) {
+      return FALSE;
+    }
+    return  $this->entityTypeManager->getHandler($entity->getEntityTypeId(), 'moderation')->isModeratedEntity($entity);
   }

This means that code that checks for this needs two check at least two methods now. What about deprecating shouldModerateEntitiesOfBundle() and testing that in isModeratedEntity() too?

Possibly as a follow-up?

Sam152’s picture

This means that code that checks for this needs two check at least two methods now. What about deprecating shouldModerateEntitiesOfBundle() and testing that in isModeratedEntity() too?

Possibly as a follow-up?

I don't think it will be possible to deprecate, since there'll be contexts where there is no actual entity but decisions need to be made about entity types and bundles.

It does raise a good question though, should the isModeratedEntity handler method include an && on the return of shouldModerateEntitiesOfBundle. My initial feeling is: no, since this isn't designed as an API for callers but as an API for implementors.

Sam152’s picture

Issue tags: -Needs change record

Added the change record: New isModeratedEntity method added to moderation entity handlers

@Berdir any thoughts on #17?

Berdir’s picture

Works for me, that we sometimes don't have an entity is a fair point, and as I said, the actual API when having an entity is ModerationInformation::isModeratedEntity(), so nothing changes.

Sam152’s picture

Status: Needs review » Reviewed & tested by the community

Okay great, thanks. Setting back to RTBC.

Status: Reviewed & tested by the community » Needs work

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

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.

Sam152’s picture

Status: Needs work » Reviewed & tested by the community

Random fail.

  • larowlan committed 695846b on 9.1.x
    Issue #3044292 by johnwebdev, Sam152, Berdir: Inline content blocks...
larowlan’s picture

Title: Inline content blocks created by layout builder should not directly be impacted by content moderation » [backport] Inline content blocks created by layout builder should not directly be impacted by content moderation
Version: 9.1.x-dev » 9.0.x-dev
Issue tags: +Bug Smash Initiative

Crediting @Berdir for reviews

Tagging this as bug-smash initiative as I've come back to it after it came up in our fortnightly meeting.

Fixed on commit

-    return  $this->entityTypeManager->getHandler($entity->getEntityTypeId(), 'moderation')->isModeratedEntity($entity);
+    return $this->entityTypeManager->getHandler($entity->getEntityTypeId(), 'moderation')->isModeratedEntity($entity);

Committed 695846b and pushed to 9.1.x. Thanks!

Leaving as RTBC and moving to 9.0.x

Will poll other committers about a possible backport - the issue here is we're adding a new method - which we normally only do in a minor release - because in theory a handler may already have a similarly named method, but with a slightly different signature - and in that case a backport would break that.

jungle’s picture

FYI here introduced a typo "apears" in core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php

alexpott’s picture

Here's a patch with the fixed spelling mistake and also a coding standards fix...

larowlan’s picture

Title: [backport] Inline content blocks created by layout builder should not directly be impacted by content moderation » Inline content blocks created by layout builder should not directly be impacted by content moderation
Version: 9.0.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

Discussed this with @catch - as we're adding a new method here, there is risk of disruption. As this is only a normal bug, this will be 9.1.x only.

Thanks all.

Sam152’s picture

Thanks folks, I've published the CR.

Status: Fixed » Closed (fixed)

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