Problem/Motivation
We need to add support for revisions and content moderation workflow for groups.
This issue only intended to provide revisioning functionality for group entity type, not for group content(pages, users, etc).
Overlaps a lot with #2850377: Have a group status field that affects access -- possibly duplicate.
Proposed resolution
The code to provide this functionality is large, then to make it easier to review will be splitted in the following issues:
- #2873212: Add a status to the group (Publish/Unpublish)
- #3029907: Make groups revisionable
- #3029908: Add revisions tab on groups
The patch on this issue will be a combination of those child issues.
Dependencies
Remaining tasks
- Get child issues RTBC.
- Get this issue RTBC.
User interface changes
All the fields needed to publish and manage content moderation for groups.
Data model changes
Add status field and revisions tables for groups.
Original issue reported by @gokulnk
I spent some time of the Group module settings and was not able to spot the configuration for the revisions. Does group module support revisions.
Can we use this approach(https://www.drupal.org/docs/8/api/entity-api/making-an-entity-revisionable) for enabling revisions for groups?
Comments
Comment #2
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI am interested in this too since I found that panelizer depends on revisioning if you wish to use it to override the layout of the main group page.
Comment #3
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedHere is an initial patch based on the linked article. I had to completely uninstall group before using this patched version of the module. This has no upgrade path so this should be considered if you wish to try it out. We need an upgrade path in order to use this. Pretty sure we just have to add some columns upon upgrade, namely vid.
Comment #4
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedComment #5
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedSo taking some time this morning to document differences after enabling revisions by uninstalling group then installing with the patched version of the module:
The revision_id on this table:
New tables:
Comment #6
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedAnd here is what data looks like in those tables:
Comment #7
kristiaanvandeneyndeHistorically, Group has not supported revisions on its entities. This was in part because we'd be revisioning someone's "key chain" (membership). To avoid confusion or weird access scenarios, we chose not to handle revisions.
However, I'm inclined to add revision support, but I've had to learn the hard way that adding something like that after the fact is far from easy. I went through writing a long update hook to enable translation support a while ago. If we can write an update hook that both enables revision support on groups and makes sure that existing websites will not suffer from it, I will commit it.
We can then still discuss whether we want to allow group content to be revisionable as well.
Comment #8
realityloopI've found this issue while looking for a way to allow a group role to revert revisions on only their group content, is that what this issue is about?
Comment #9
marthinal CreditAttribution: marthinal at Bluespark commented1) We need revisions but only for Group. I've been working on it and it seems that my patch works as expected:
See: https://www.drupal.org/docs/8/api/entity-api/converting-a-content-entity...
2) Entity contrib module is required. See #2350939: Implement a generic revision UI
3) I had this problem: #2919648: menu_link_content_entity_predelete() must not fatal if entity URLs cannot be generated. I fixed the error from Group::urlRouteParameters()
4) Implemented group_post_update_set_values_revision_table() because revision_created and revision_user cannot be NULL. Otherwise we have exceptions from Drupal\entity\Controller\RevisionOverviewController::getRevisionDescription()
Comment #11
fran seva CreditAttribution: fran seva as a volunteer and at Bluespark commentedI have re-rolled the patch.
Comment #13
scotwith1tAdding related Core issue. @kristiaanvandeneynde says:
Stay tuned...
Comment #14
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedHere are some modifications:
That said this patch is only to be used on new sites without existing groups.
Comment #15
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedFor changes in the use declarations of src/Entity/Group.php is not possible to apply this patch alongside with #2797793: Entities identified by strings as group content, so if someone is interested on use both I created this combined patch.
Comment #16
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedAdded granular permissions and revisions page, now that #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data is RTBC I'm going to start working in the upgrade path.
Comment #18
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedAdded content moderation module to tests.
Comment #19
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedIn my opinion, this patch is doing way too much so it's hard to review properly. I would suggest to split it up in at (at least) three parts:
- adding a publishing status to the
group_content
entity type- convert the
group_content
entity type to revisionable- split up the current
entity_id
field into two separate fieldsIf you agree with that and open separate issues for each of those tasks, I can help with reviewing and providing guidance for the first two items :)
Comment #20
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedHi @amateescu,
Thank you for your advice, I will follow your suggestions:
I started creating the patch for publishing status using and existing issue #2873212: Add a status to the group (Publish/Unpublish), also I will update this issue as parent for all the issues related to support revisions on Group entity type.
Comment #21
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedComment #22
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedAdded patch only for conversion to revisionable on #3029907: Make groups revisionable.
Comment #23
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedThis is the full patch with the patches from the three child issues combined.
Comment #24
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedChanged status, because it passed all tests.
Comment #25
kristiaanvandeneyndeCan we use the new functionality that was just added to core for this? #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data
See change record: https://www.drupal.org/node/3029997
Although that would mean we are blocked until May 1st 2019 because that's when core 8.7.0 releases :/ I've not reviewed this issue yet, but if it ships with thorough testing (including an update hook test), I may consider committing this to Group 8.1.0. If everything else is cleaned up and this issue is not in an acceptable state yet, we might want to cut Group 8.1.0 and fix this in 8.1.1 using the update path provided by core 8.7.0.
Comment #26
kristiaanvandeneyndeAlso, thanks @amateescu for chiming in. Your expertise on this subject matter might prove invaluable!
Comment #27
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedThis patch is already working with #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data based on your recommendation via Slack, the only thing missing are some tests.
Here I'm just including some fixes for the revisions tab and revisions reverting functionality, also included in #3029908: Add revisions tab on groups for easier review.
Comment #28
fran seva CreditAttribution: fran seva as a volunteer and at Bluespark commentedHi @jidrone, I read in #14 the patch should not be applied in sites with created groups, in my case I used #9 patch and when I try to apply your last patch I have an error updating, the problem is the columns in group_revision table are different to those created by patch #9.
Do you think once this feature is complete will be a way to conciliate those sites with patch #9?
Note: I have updated the patch to fix the error I found when I try to apply #9 into last dev version, that way I will be able to use revisions.
Comment #29
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedHi @fran seva,
The latest patch I uploaded, can be applied in sites with existing groups, because it support the update by using this #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data, for that reason I think is not possible to conciliate those patches because both process the update in a different way.
Comment #30
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedAdded some improvements on revisions tab and some tests.
Comment #31
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedFixed some comments in tests.
Comment #32
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedHi Everyone,
Now that #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data is in the core from the beginning of this month, we can proceed to review a merge this patch, can someone help review the remaining 2 child issues?
Comment #33
igorbarato CreditAttribution: igorbarato commentedHello @jidrone,
I updated the hook_update ID and added a validation when a group hasn't a revision.
Comment #35
igorbarato CreditAttribution: igorbarato commentedComment #36
igorbarato CreditAttribution: igorbarato commentedComment #37
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedHi Igor, can you please provide an interdiff.
Comment #38
igorbarato CreditAttribution: igorbarato commentedHello @jidrone,
I added the patch again with the interdiff file. I have a question: the Group Revisions works only the Content Moderation is enabled?
Comment #39
igorbarato CreditAttribution: igorbarato commentedComment #40
igorbarato CreditAttribution: igorbarato commentedComment #41
dwwSadly this is duplicating a ton of effort with #2850377: Have a group status field that affects access (which I've only skimmed, but is massively overlapping).
I don't want to mark either one duplicate until I can closely review to decide which approach seems more viable, but it should probably be that one that's marked dup (since it's newer). Would @jidrone and/or @igor.barato be willing to do a closer review and see if the approaches can be merged and #2850377 closed?
Comment #42
Deno CreditAttribution: Deno commentedJust some food for thought:
I have recently learned how to write a business rule that allows me to work with inline entity forms within the group.
That is, I can add and remove referenced entities directly from the group edit form(s) now and the business rule assures that they get added to the group or removed from it as necessary.
This even works well with translations.
However, the revisions are a problem. For one thing, I'm not even sure what would be a "correct" behaviour when a group is rolled back. Would all the group entities also be rolled back? Do they even have the synchronised revisions? Should they?
I can see two scenarios that make sense here:
1) either all group entities roll back to the same version with the group.
2) Or an easy way is provided for people to work with versions of the group entities - e.g. from the group entities overview page.
Making new version for all group entities every time the group is updated may be interesting for small groups, but this would kill the server in case of big groups with many entities. So it's basically just the second option.
Comment #43
jidrone CreditAttribution: jidrone at Mobomo for Vibrent Health commentedHi everyone,
These are my thoughts for the last 2 comments:
#41:
This patch not only provides the status property for group entities, but it also adds the revisioning functionality.
The status property added in this case is the standard boolean property needed for all revisionable entities so this is the right way to add this functionality.
Regarding a possible duplicated effort, you can see this comment https://www.drupal.org/project/group/issues/2873212#comment-12951819 there is a similar concern and my answer was that I prefer first to cover the standard status functionality and then we can provide a feature to restrict the group content access based on that.
#42:
This is a similar situation than using paragraphs in groups, it uses an entity reference revisions field typed provided by Entity Reference Revisions which makes possible to generate the relation with the revision, there is an issue related to that #3025709: "Create new revision" option is ignored when updating EntityReferenceRevisionsItem.
In my opinion, if the entities are rendered within the group entity view(like paragraphs) they should generate a new revision of the parent group when they are changed.
Comment #44
Deno CreditAttribution: Deno commentedHm, that's an interesting idea. I tried out using the inline entity form with entity reference revision field, but that didn't work. I can try it again...
Comment #45
Deno CreditAttribution: Deno commentedHm, that's an interesting idea. I tried out using the inline entity form with entity reference revision field, but that didn't work. I can try it again...
Comment #46
jwilson3#38 no longer applies to 8.x-1.0-rc5 (current head)
This is a manual re-roll with an interdiff-38-46.txt file containing only the hunks that succeeded (i.e. this interdiff-38-46.txt is technically incomplete) along with a pseudo-interdiff-38-46.txt which contains a more accurate (but less readable) output from:
Things that I've changed are superficial:
use
to be alphabetical.Comment #47
jwilson3Whoops. Problem with manual rerolls is they're hard to get right, even with interdiffs.
This one fixes a few whitespace and syntax errors introduced accidentally in #46.
Also let's hide a bunch of old patches at the top of the issue.
Comment #48
dwwIt's a bit sad to see giant patches still being posted here, instead of the smaller, easier to review patches in the child issues. Can we please stop doing that and focus our collective efforts on the child issues, instead?
Thanks!
-Derek
Comment #49
jwilson3@Dww: The reason is many fold. But primarily, the problem working in the sub-tickets is that the patches are not compatible, and cannot be applied in succession on a codebase, because they generate conflicts.
For example, merging 3029907-group-make-revisionable onto 2873212-group-status creates the following conflicts that must be resolved manually:
I'm in the process of rebasing all three sub-issues on latest 8.x-1.x branch, since all need rerolls. Then, I'm going to also reroll patch in #47 on latest 8.x-1.x branch and manually compare the differences between each and then push down any changes that I made above into the sub-issues, if there are any that make sense.
Comment #50
jwilson3I've found a number of differences between the sub-tickets and the latest patch here. Aside from formatting issues and some minor code order changes that have no effect on functionality, there are some things that have been worked on here that have not ended up in the sub-tickets, including tests and a few smaller chunks of code.
Comment #51
jwilson3Due to aforementioned conflicts with the sub-issues, I've recreated the patch on this issue to be based on merges with manual conflict resolution of the three sub-issues into a single branch using the following:
Comment #52
jwilson3@dww, you'll also note on the sub-issues that splitting this issue apart breaks tests that were added in this issue (because one issue requires another).
All three sub-issues are so intertwined that it really makes no sense to pull them apart except literally to make it easier to review. Those sub-issues should not be merged and cannot even be used to write tests.
All this complexity around the issue is going to make it super challenging to get this issue committed in the first place. *sigh*.
To explain a few of the interdependencies:
1. Revision-based permissions in #3029907 depend on status permissions in #2873212.
('View the latest version' 'Requires the "View any unpublished group" or "View own unpublished group" permission')
2. But also 3029907 doesn't apply cleanly after applying 2873212.
3. Revision tests in 3029908 depend on code in 3029907.
(Exception: Error: Call to undefined method Drupal\group\Entity\GroupType::isNewRevision())
4. But also 3029908 doesn't apply cleanly after applying 3029907.
Comment #53
jwilson3Bumped patch from sub-ticket #2873212 comment #27 to fix syntax error.
Edit: you'll note that tests that don't execute in the sub-tickets run fine once merged together here.
Comment #54
maxwellkeeble CreditAttribution: maxwellkeeble commentedAttached the same patch as #53 with the group_update changed to allow for patching 8.x-1.1.
Comment #55
dimitriskr CreditAttribution: dimitriskr commentedHere's a reroll for latest , small changes with #54's patch, applies cleanly at 6bc592d4
Given the order jwilson3 gave at #52 (2873212->3029907->3029908) of applying the child patches is correct, I have changed the latest ones on the childs in order to be applied cleanly. I will test them more on the dev and upload them to their issues soon
Comment #56
SadySierralta CreditAttribution: SadySierralta at Metadrop commentedI have made small changes to allow the patch to work on D9.
Applies at 9b469da.
Comment #57
jwilson3NW. One of the sub-issues has an RTBC patch that has not been incorporated here yet, see patch on comment #36 of #2873212-36: Add a status to the group (Publish/Unpublish).
Comment #58
dimitriskr CreditAttribution: dimitriskr commentedHere it is. let's see the tests
Comment #59
dimitriskr CreditAttribution: dimitriskr commentedSorry, wrong naming on the patch
Comment #62
dimitriskr CreditAttribution: dimitriskr commentedLet's try again
Comment #64
jwilson3Those failures on #62 seem spurious. Not sure what that is on about.
But also: an interdiff between #56 and #62 would be helpful given the size of the patch, and would also allow us to compare with the interdiff on #2873212-36: Add a status to the group (Publish/Unpublish).
Comment #65
dimitriskr CreditAttribution: dimitriskr commentedThe patch on #62 had some issues and are fixed on this patch. Maybe this is the problem for the test fails. Crossing fingers
I made the interdiff using patchutils and it mainly shows some code-formatting changes plus the change on https://www.drupal.org/comment/13913576#comment-13913576
Comment #66
dimitriskr CreditAttribution: dimitriskr commentedThese fails are not relevant to the patch. I think I found the issue. At 1.3 the failing test was added.
Comment #67
anish.a CreditAttribution: anish.a at QBurst commentedSince #2873212: Add a status to the group (Publish/Unpublish) is committed, we need to consider changing this patch. Are we splitting this into three tickets, or continuing working on this?
Comment #68
anish.a CreditAttribution: anish.a at QBurst commentedComment #69
kristiaanvandeneyndeAll of the child issues are fixed now. Just waiting for a few reviews.
Small notes:
Comment #70
mmbkThe patch #65 does not apply to v1.4 anymore, as far as I can see in the moment it is because of the applied child issues.
Comment #71
anish.a CreditAttribution: anish.a at QBurst commentedI think this feature is already released. Need to close this ticket.
Comment #72
kristiaanvandeneyndeYeah, as this was an issue that pasted the patches from all 3 child issues together, I forgot to close it. I can add credit for people who contributed here to one of the child issues if they haven't received credit in any of those three yet. Just let me know if that's the case for you and then we can circle back and close this one.