Problem/Motivation
In core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php, there is no check done if the node bundle is actually under workflow moderation or not and create new revision is forced.
Proposed resolution
We need to have better check here to ensure we don't force this.
Remaining tasks
Review and commit!
User interface changes
Revisions no longer forced for non-moderated bundles.
API changes
None.
Data model changes
None.
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 2946750-29.patch | 5.81 KB | sam152 |
| #29 | 2946750-29-TEST-ONLY.patch | 2.15 KB | sam152 |
| #29 | interdiff.txt | 895 bytes | sam152 |
| #19 | 2946750-19.patch | 5.49 KB | sam152 |
| #15 | 2946750-15.patch | 5.36 KB | sam152 |
Comments
Comment #2
merauluka commentedI agree that this behavior is not ideal. I recently ran up against this when reviewing the migration path from Workbench Moderation to Content Moderation. It appears that this behavior was in Workbench Moderation and was carried over into Content Moderation. However, now that moderation can be applied on a per content type basis with custom workflows, I think this deserves another look.
I have created a preliminary patch that checks the if the node type or node being editing is subjected to moderation before enforcing the revisions box to be checked. In testing on my local, this resolved the issue and appears to work well. I'm submitting it here for review by the community.
Comment #4
merauluka commentedResubmitting a new patch with the correct relative path.
Comment #6
merauluka commentedRerolled the patch against 8.5.1 and 8.5.x-dev since there was a change to the module in the meantime.
Comment #7
merauluka commentedSo it appears that this feature is written into the tests on Content Moderation. So the tests will also need to be patched in order to get this feature to pass build tests. Back to the drawing board.
Comment #8
timmillwoodThis should fix the failing tests, but I still think this needs more test coverage.
Comment #9
timmillwoodMoving back to needs work for more test coverage, specifically around
\Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsEntityFormAlter.Comment #10
merauluka commentedAdding a related issue.
Comment #11
sam152 commentedI think we should actually never call
enforceRevisionsEntityFormAlterif the bundle is not being moderated.That way we fix the issue in one place for all handlers, instead of just for node. Block content will still be broken for example.
Comment #12
sam152 commentedWe don't actually have to change
enforceRevisionsEntityFormAlter, that was working already.I did however notice we have a redundant check in
\Drupal\content_moderation\EntityTypeInfo::formAlter. We checkisModeratedEntityEditFormwhich already checksisModeratedEntityfor us, so removing that.Comment #14
sam152 commentedFixing the test case.
Comment #15
sam152 commentedWhoops, removing unrelated file from patch.
Comment #17
lobsterr commentedI have tested it. It works perfectly for me
Comment #19
sam152 commentedReroll.
Comment #20
dercheffeHi @all,
I would vote for making this issue a major one, because this problem inflates the DB of a site unnecessarily and can bring massive performance problems.
Comment #21
sam152 commentedPatch still applies, queuing another test.
Comment #23
dercheffeApplied patch in #19 at my Drupal 8.7.8 and it's solving the problem.
Comment #24
catchShouldn't this also have a test to ensure the revision checkbox isn't checked/disabled when a bundle isn't moderated?
Comment #25
smaz+1 for this fixing the issue for me, not marking as RTBC due to the question about the test above.
Comment #26
webdrips commented+1 #19 applied cleanly to 8.8.5 and seems to work just fine.
Comment #28
ccjjmartin commented+1 functionally works great, thanks for the effort here all, not marking as RTBC as mentioned above because I agree the test should be updated to include verifying that the checkbox isn't disabled (since that is what I did manually to verify this was working).
Comment #29
sam152 commentedThanks for the reviews, adding those additional asserts and a red/green patch. Also cleaning up the issue summary a bit.
I decided not to assert the checked status of the revisions checkbox before enabling content moderation, because CM shouldn't be tweaking that and it's a default that comes from the node module.
Comment #31
jibran#24 is address so back to RTBC.
Comment #32
alexpottCommitted and pushed 30c286f45d to 9.1.x and 09fe2d3e69 to 9.0.x. Thanks!
Comment #35
alexpottLeaving at backport for 8.9.x and kicking off a test.
Comment #36
alexpottCherry-picked back to 8.9.x