Problem/Motivation
As decided in #2745619: [policy, no patch] Which core entities get revisions?, comments should be converted to be revisionable.
Quoting @webchick from #2745619-9: [policy, no patch] Which core entities get revisions?:
Would allow some recourse for content administrators to go after a malicious user who filled their comment with a bunch of racist garbage to which other users reacted, and then later went back and edited their comment to something more innocent, to dodge being banned.
Proposed resolution
Do it.
Remaining tasks
Review.
User interface changes
None yet, revision support is only enabled at the API level.
API changes
Nope.
Data model changes
Comments are now revisionable.
Comment | File | Size | Author |
---|
Issue fork drupal-2880154
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:
Comments
Comment #2
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis depends on #2346019: Handle initial values when creating a new field storage definition, #2854732: Use initial values for content translation metadata fields and fix existing data and #2860654: Field storage CRUD operations must use the last installed entity type and field storage definitions.
Comment #3
andypostPlease update IS about why comments "should" become revisionable by defalt
Comment #4
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedIt's in the issue summary of the parent issue, but ok, cross-posted here as well.
Comment #5
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNo more blockers! Here's a fresh patch for the testbot.
Comment #7
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedLet's fix it.
Comment #8
timmillwoodLook good!
Yay, now we can load comment revisions!
Comment #9
tstoecklerNit: s/custom menu links/comments/
Comment #10
timmillwoodOops, missed that.
Could be done on commit, but to keep things moving along, here's a patch.
Comment #11
Wim LeersThis is technically a BC break for API-First… I'll let core committers decide here.
Comment #12
timmillwoodComment #13
BerdirContent entities are by definition extensible, I don't see how adding more fields is a BC break? That would mean that I could introduce a BC break for Drupal by adding a field in the UI? :)
Then any improvement that adds more stuff to the serialized output would be a BC break too, e.g. exposting things like file url/image style urls, formatted text and so on.
To be clear: This is far from a trivial change, switching out the table storage could break a lot of stuff if people query database tables directly. Although making an entity type revisionable is far less problematic than making it translatable, because we don't really touch the existing tables that much, otherwise a lot of our custom threading queries and so on would be broken too. But those additional fields in the serializer seem like the least of the possible problems IMHO :)
Comment #14
Wim LeersThe difference is that this affects every Drupal site using this entity type. Adding more fields is usually a manual operation: if I add additional fields, I'll know I'm changing the data model, and I'll know I'm changing my REST/JSON API responses.
That's a very big difference.
Yep! And this is why it's so painful to work on API-First: because every improved normalization requires a BC layer. This is why we have
bc_entity_resource_permissions
in REST andbc_primitives_as_strings
+bc_timestamp_normalizer_unix
in Serialization: all these improved normalizations are disabled by default, you have to opt in to them manually.We'll need similar BC layers for every single thing you mentioned. Without those BC layers, they'd never have been committed.
I do agree that adding more fields is less of a BC break than changing the normalization of a field! But it's still a BC break.
That's why I didn't mark this NW. That's why I said
and : because I think this is a reasonable change, with a manageable amount of disruption. But it's still totally possible that this is going to break some decoupled applications. And at minimum, this will need a change record, to warn those sites.(Also, if it lands, it ought to get an entry in the 8.4.0 release notes!)
Comment #15
timmillwoodAdded a provisional change record https://www.drupal.org/node/2897893
Comment #16
BerdirBoth of those two are different in that they *change* existing structure/behavior. That's not the same as adding propertes/fields that didn't exist before.
We're allowed to add methods to most classes, we're allowed to add the actual fields to the entities (and add and change database tables!), I don't see why we wouldn't be allowed to expose those fields in the serializer. That's how the serializer works by definition IMHO, it dynamically exposes all available/accessible data, as I've said elsewhere, if you require a 100% stable, identical output for your client, then you should write your API. If that is not as clear to you/others as it is to me, then we should document that explicitly on https://www.drupal.org/core/d8-bc-policy. #2716081: BlockContent should have revision_user and revision_created fields and implement RevisionLogInterface is an example that also added additional fields to block_content for example.
But yes, we definitely need a change record here, because as I said, making the entity type revisionable, adding the revision id and other fields is likely going to affect some sites. I'm definitely not arguing against that :)
Comment #17
Wim LeersI'm strongly in favor of documenting the BC promises around REST responses and normalizations at https://www.drupal.org/core/d8-bc-policy! I think that demanding that clients allow additional keys (whether they be fields or properties) to show up in normalizations is a totally fair expectation. I'd love to see that documented there.
All I'm saying here is that this change has the potential to break API clients, and therefore it's technically a BC break, and we should pay close attention to it.
Comment #18
Wim LeersOh and yes, the same problem applies to #2716081: BlockContent should have revision_user and revision_created fields and implement RevisionLogInterface, but I never saw that one until now, and that entity type still doesn't have REST test coverage, so it was easy to miss. #2835845: EntityResource: Provide comprehensive test coverage for BlockContent entity is still in progress.
Comment #19
Wim LeersCR updated: https://www.drupal.org/node/2897893/revisions/view/10579311/10580834
Comment #21
timmillwoodreroll
Comment #22
timmillwoodGoing back to RTBC because I RTBC'd @amateescu's patch in #8, since then I fixed a nitpick and performed a reroll.
@Wim Leers and @Berdir make some good comments regarding backwards compatibility but I'm not sure there is any way around this. The awesome CR updates from @Wim Leers really help, so let's get this in and start to make more things revisionable in 8.4.0
Comment #24
Wim Leers#22++
Comment #25
timmillwoodAs this is already RTBC it should be fine for 8.4.x
Comment #26
xjm@timmillwood reached out to me about whether this issue is still eligible for 8.4.x. It's a distruptive change, so it should remain filed against 8.5.x generally. During the alpha phase, disruptive changes may be backported at committer discretion after commit. The fact that the issue was RTBC for the past couple weeks is taken into account but does not necessarily mean it will be backported.
In the case of this issue, though, it's a strategic priority, so I would indeed like to backport it if we commit it in time for the beta freeze deadline on Aug. 15, unless other committers raise concerns. Leaving the branch at 8.5.x though; we make the final decision after commit.
Thanks!
Comment #27
xjmI talked to @larowlan about this issue and we're a little concerned about the risk and disruption. For example, the related taxonomy issue introduced regressions for the term overview page. It might be best to commit issues like these and #2820848: Make BlockContent entities publishable to 8.5.x early so we have the full development release to test them.
Comment #28
timmillwoodI can understand the concern for this issue but not for #2820848: Make BlockContent entities publishable. Making BlockContent entities will really help Content Moderation, because it will be possible to archive a block and it will not be visible to users. Currently when BlockContent Entity is archived it is still visible on the site.
Comment #29
timmillwoodI've been taking a look at possible risks of committing this to 8.4.0:
I hate to say this, but pushing to 8.5.x might be a wise choice.
(Although still sure publishing BlockContent entities will be fine for 8.4.0)
Comment #30
xjmThanks @timmillwood. Some of those things sound like they might be blocking to me. The first one in particular is a UX regression for a pretty common usecase (anonymous comments). Let's file separate issues for each point and postpone this issue? Setting NR for now.
Comment #31
benjy CreditAttribution: benjy at Unearthed commentedI re-rolled this because I wanted to test the update path. Are the revision user and creation times meant to be pre-filled from the original entities, because they are empty after the update.
Comment #33
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@benjy, I did not consider adding an initial value for those fields but you're right, we probably should :) Here's a patch that does that and also fixes the test fails and coding standards of the reroll.
Comment #34
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis patch fixes #29.1 and starts to fix #29.3 but I'd rather wait for #2915398: The moderation_state field is not computed during the creation of a new entity translation. before going any further.
Comment #35
benjy CreditAttribution: benjy at Unearthed commentedOops, I did actually post a patch with the initialValueFromField fix but I posted it to the wrong issue! Unable to convert a non-translatable entity into a revisionable entity - That worked well for me.
Comment #36
Wim LeersPer #34.
Comment #38
matsbla CreditAttribution: matsbla commented#2915398: The moderation_state field is not computed during the creation of a new entity translation. fixed.
Comment #40
gappleUsing the same approach as #2880149: Convert taxonomy terms to be revisionable to use #2984782: Add an API for converting entity type schemas to (non-)revisionable/(non-)translatable, with or without data
Comment #42
slashrsm CreditAttribution: slashrsm at Tag1 Consulting commentedThis is a 8.6 re-roll of #34.
Comment #43
slashrsm CreditAttribution: slashrsm at Tag1 Consulting commentedThis is a 8.7 re-roll of #34.
Comment #45
patrick.thurmond@gmail.comDeleted by user. Sorry, posted this to the wrong issue page. I was working on fixing a patch for ECK and had this issue open as well. Just put it in the wrong place.
Comment #46
patrick.thurmond@gmail.comComment #48
Ericmaster CreditAttribution: Ericmaster at Isovera commentedLast patch had an issue which was breaking configuration synchronization when attempting to enable Content Moderation module. Added a condition to fix that and re-rolled the patch for 8.9.x.
Comment #49
marvil07 CreditAttribution: marvil07 at Isovera for Pegasystems commentedHere an interdiff for the last patch.
Comment #54
sreenivasparuchuri CreditAttribution: sreenivasparuchuri as a volunteer commentedI updated to D9, but the patches above do not apply. My current version is 9.2.10. Can some one guide me what need to be changed
Comment #55
steinmb CreditAttribution: steinmb as a volunteer commented@sreenivasparuchuri - The patch is just old and needs be rerolled against 9.3.x
Comment #56
andypostit needs reroll against 9.4.x as 9.3 in release freeze
Comment #57
karishmaamin CreditAttribution: karishmaamin at Specbee commentedRe-rolled against 9.4.x. Please review
Comment #58
karishmaamin CreditAttribution: karishmaamin at Specbee commentedComment #59
ranjith_kumar_k_u CreditAttribution: ranjith_kumar_k_u at Zyxware Technologies commentedFixed CS issues.
Comment #60
Kojo Unsui CreditAttribution: Kojo Unsui commentedI can't apply any of these patches. At the moment I have to stick with Core 9.1.6, and I get the following error
and indeed it seems SqlContentEntityStorageSchemaConverter was deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::updateFieldableEntityType() instead. (source).
Could you point me in the right direction please ?
Comment #61
niles38 CreditAttribution: niles38 commented@Kojo Unsui I'm getting the same. I'm going to look into creating another patch to test it with 9.3.6.
Comment #63
sreenivasparuchuri CreditAttribution: sreenivasparuchuri as a volunteer commentedI am using 9.3.13, and i have comment enabled, and after using this patch, when i saved the Comment form display, I am seeing below error
This is due to the code in core/modules/comment/src/Entity/Comment.php
As per the https://www.drupal.org/node/2801513 , 'type' => 'hidden', causes issue, I am adding new patch where i replaced the that code
Before
After
Comment #65
Shubham Chandra CreditAttribution: Shubham Chandra as a volunteer and at Dotsquares Ltd. commentedReroll the patch #59 with Drupal 9.5.x
Comment #67
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #65 discards the changes from #63. I'm going to reroll against #63 and replace the usage of
\Drupal\Core\Entity\Sql\SqlContentEntityStorageSchemaConverter
with\Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::updateFieldableEntityType()
.Comment #69
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI started a MR with the patch from #65, rebased and changed the following things:
SqlContentEntityStorageSchemaConverter
revision_created
andrevision_user
fields to fix an issue when displaying the revisions overview, as discussed in #2350939.I also created Comment Revision UI, a module using the work from #2350939: Implement a generic revision UI to implement a revision UI for comments.
Comment #70
dpiLeft a note on MR.
Comment #71
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedCommented.
Comment #73
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedAddressed Drupal CS issues of MR.
Comment #74
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedShouldn't we also add a
new_revision
field to comment types like node types have, and implementCommentType::shouldCreateNewRevision()
?Comment #75
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #76
smustgrave CreditAttribution: smustgrave at Mobomo commentedSeems to be some failures in the MR2872
Also the update hook will need upgrade tests.
Comment #78
robphillips CreditAttribution: robphillips commentedProbably should update
comment_user_cancel()
so thatrevision_user
is re-assigned to zero (0) when the author's account is cancelled. I recently ran into an issue where the comment was re-assigned but not the revision. Seenode_user_cancel()
as an example: