Closed (fixed)
Project:
Drupal core
Version:
8.2.x-dev
Component:
content_moderation.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Aug 2016 at 08:51 UTC
Updated:
28 Jul 2017 at 00:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
timmillwoodComment #3
timmillwoodComment #4
timmillwoodMarking this as a contrib blocker because Workspaces (as defined by Multiversion module) are not translatable, but we want them to be moderated. This currently works fine with Workbench Moderation, but doesn't with Content Moderation.
Comment #6
dawehnerI'm wondering whether we could somehow test
content_moderationwith all kind ofentity_testentities, which should give us test coverage for all kind of edge cases.Comment #7
timmillwood@dawehner an entity type can only be moderated if it has a bundle and is revisionable. Therefore I'm not sure if entity_test entity types will work because they don't have bundles. However we could look at refactoring Content Moderation to not depend on bundles. The only reason it currently requires bundles is because this is where the moderation settings are stored.
Comment #8
dawehnerComment #11
timmillwoodNot sure how best to tackle the "Needs tests" tag on this.
I'd like to address it in a follow up, either:
- Update content moderation to allow moderation on entity types without bundles. This could be done by either having moderation settings in the UI on the bundle as it is now and / or on the entity type via the annotation or hook_entity_type_alter.
- Change entity_test to have bundles.
Comment #12
timmillwoodAdding tests... but annoyingly, the test_only.patch passes locally too, when it shouldn't.
That can wait until tomorrow.
Ended up adding an EntityTestRevType bundle for EntityTestRev to use.
Comment #15
dawehnerI'm glad you don't have the problem that the tests aren't passing on drupal.org :P
Comment #16
timmillwoodok, lets hope for better luck this time.
Even though entity_test_rev is not translatable it still has a langcode, so removed that.
entity_test.install was adding some fields, but we needed a bundle first, so generating that too.
Comment #19
timmillwoodFixing some of the failing tests.
Any suggestions welcome on the other one.s
Comment #21
timmillwoodEven though it won't pass, uploading a patch as I won't be looking at this again until Tuesday.
On @amateescu's suggestion I've been reworking to use EntityTestWithBundle entity, rather than trying to add a bundle to EntityTestRev. The issue is EntityTestWithBundle is not revisionable, so trying to make it revisionable by entity_test_entity_type_alter. However I'm struggling to get this to fire before content_moderation_entity_type_alter fires, because this is where the moderation handler gets added, which is used to make an entity type moderated.
Interesting and fun suggestions welcomed.
Comment #22
timmillwoodComment #24
timmillwoodMaking EntityTestWithBundle revisionable.
Wonder if it breaks anything.
Comment #25
amateescu commentedFollowing up on #21, all we need to do in order to get
entity_test_entity_type_alter()to fire beforecontent_moderation_entity_type_alter()is to implementhook_module_implements_alter()and move 'entity_test' to the beginning of the array.Here's a patch that does that and also cleans up the test a little. Interdiff is to #21.
Comment #27
timmillwoodThanks @amateescu!
Looks good to me!
Comment #28
xjmThis is rc eligible as an experimental module improvement, per: https://www.drupal.org/core/d8-allowed-changes#rc
Comment #29
alexpottThe rtbc in #27 is not really right - much of the work in the patch is @timmillwood's. The patch looks good to me but committing from this state sets a bad precedent.
Comment #30
dawehnerJust a question for a follow up: Is it worth to have this additional if here in the first place? Why not get always the translation. All objects are available anyway.
Comment #31
alexpottI wonder if this could break contrib tests that use EntityTestWithBundle? Making this test entity non translatable seems like an unexpected change for this issue - how about we just make a new type?
Comment #32
sam152 commented#2812811: Use EntityPublishedInterface during moderation of entities to add support beyond nodes introduces a few new test entities. Maybe langcode can be removed from EntityTestRevWithBundle there?
Comment #33
timmillwoodThere is no
translatable = TRUEannotation in EntityTestWithBundle, so in theory it's not translatable, it just has a langcode entity key.Although the issue this patch is trying to fix doesn't apply on entity types with langcode entity keys, so had to remove it to make this fail.
I'm all for making EntityTestWithBundleNonMul, but if we do that then maybe we should make EntityTestWithBundle actually translatable.
Comment #34
amateescu commentedIt seems weird that some entity types which are not translatable define the 'langcode' key, so I opened #2818379: Remove the 'langcode' entity key for non-translatable entity types to discuss that.
Comment #35
amateescu commentedI discussed the issue mentioned above with @Berdir and it seems there is a valid use-case for a non-translatable entity type to define the 'langcode' key, which makes me think that the patch is not actually correct, in the sense that we should check the availability of the langcode field instead of whether the entity type is translatable or not.
And, given the above, we do need to provide a new test entity type for this :)
Comment #36
timmillwoodThe biggest issue with creating a new entity type for this is we need a new bundle type too.
Working on a patch now.
Comment #37
timmillwoodWe don't need a new entity type at all, just need to edit the existing one.
Comment #39
sam152 commentedHm, in other issues I thought I ran into issues with entity_test_with_bundle not being revisionable, but if it works, awesome.
Edit: Ah, I can see you are making the entity revisionable. It looks like we have a few tests popping up that require that functionality. Is there really much overhead to a few new test entity types that cover the cross-section of entity features that we need? Altering the entity definitions in that manner might become tedious?
Comment #40
timmillwoodFor small things, like entity key changes altering makes much more sense to me because there are so many possible combinations if we start adding:
etc
Comment #41
sam152 commentedLooks like the pattern is already in use, so it's an RTBC from me.
Comment #43
timmillwoodRe-queued #37 as it was only failing due to curl timeout putting back to RTBC.
Comment #44
timmillwoodResolving #35
Comment #45
amateescu commentedMissed a spot :)
The new test method is an exact copy of the other one, shouldn't there be a difference somewhere?
Comment #46
timmillwoodtestNonTranslatableEntityTypeModeration is not translatable, but has a langcode entity key.
testNonLangcodeEntityTypeModeration is not translatable, and doesn't have a langcode entity key.
Other than that it's the same test. So testing the same steps with or without a langcode. I wanted to make sure that if the condition is based on langcode now that is still works for non-translatable entity types if there is a langcode.
Comment #47
amateescu commentedAh, okay, maybe you can put that explanation in the patch as well? And point 1) still stands.
Comment #48
timmillwoodFixing #45.
Comment #49
timmillwoodUpdating the comments on the tests to make it clearer the difference between the two.
Comment #50
amateescu commentedNice, looks good now :)
Comment #51
alexpottImo this being in the content moderation schema shows the problem with the current approach of it handles bundles. This is rendered completely unnecessary by #2779647: Add a workflow component, ui module, and implement it in content moderation. If we want to get this in before that we need to move this schema to a test module because it is just not relevant for regular running of a site using content moderation.
Comment #52
sam152 commentedI think anything made irrelevant by #2779647 is worth holding off on for the moment.
Comment #53
timmillwoodMy fear is that #2779647: Add a workflow component, ui module, and implement it in content moderation is still a few weeks off. Therefore I'll try to reroll this with
entity_test.entity_test_bundle.*.third_party.content_moderation:in entity_test module today.Comment #54
amateescu commentedThis is also *exactly* what made me open and work on #2799785: Entity types with non-config bundles can not be moderated, which was closed in favor of the larger refactoring.
However, that refactoring is mostly better suited for 8.3.x, while this is a genuine 8.2.x bug fix so it's not irrelevant at all.
Comment #55
timmillwoodHere's the updated patch with the schema move.
Comment #56
amateescu commented@alexpott's review has been addressed, back to RTBC.
Comment #57
alexpottCommitted and pushed 144fe78 to 8.3.x and 1506901 to 8.2.x. Thanks!
@amateescu #2779647: Add a workflow component, ui module, and implement it in content moderation is 8.2.x eligible btw - content_moderation is experimental. The whole point of being in alpha is fix things like this.
Removed unused uses on commit.
Comment #61
timmillwood#2846830: Add changelog for Drupal 8.3.0
Comment #62
amateescu commentedHere's a followup to clean up the tests that were added here: #2898020: Simplify ContentModerationStateTest