Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Following on from #2490136: Enable revisions by default we should remove this option from the node form altogether, for the following reasons:
- The behaviour of sometimes saving a new revision, and sometimes overwriting the current revision, has caused myriad data loss bugs in contrib, such as #1807460: Field collection doesn't play nice with workbench moderation (patch). I had to write an entire contrib module to stop workflow modules from exploding all over the place in 7.x - see https://www.drupal.org/project/drafty / #2376839: Rewrite to use the new Drafty module / #2379071: Use drafty module for draft revision handling. Removing the option from the form would be a small step towards standardising the code flow overall.
- The decision to save new revisions or not is a site building or developer issue, not a content author one. Since entity revisions are configurable now via code, they can be set on or off at the entity level.
- It adds clutter to the node form, and an extra decision for people to take that's not related to the actual task they're doing
- It could be added back from contrib if someone really wanted it
Proposed resolution
Remove the checkbox.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#36 | 2696555-36.patch | 662 bytes | chr.fritsch |
#10 | 2696555.patch | 1.56 KB | imalabya |
Comments
Comment #2
catchComment #3
timmillwoodThis is highly dependent on #2490136: Enable revisions by default, once that gets committed I'll write the patch for this.
Comment #4
catchComment #6
catchRe-opening and tagging.
Comment #7
timmillwoodI think this belongs in "Workflow Initiative", also noticed that 5 months ago I promised to write the patch, I re-add it to the todo list.
Comment #8
dawehnerWhat will happen with the revision log field? I guess it would simply stay where it is?
Comment #9
catchI think so.
I did wonder about introducing the concept of minor revision (which wikipedia had the last time I made an edit on there about 5 years ago, not sure about now).
That's subjective of course, but creating a new revision or not is also subjective.
This minor vs. not could then be used in the revision/diff UI and potentially for pruning old revisions. However not sure that has to be in core at all.
Comment #10
imalabyaAdded an initial patch for removing the checkbox and save the revisions by default. I guess it needs test.
Comment #12
tstoecklerThis comment is out of date. Maybe we can just add "and set the current user as the revision author." to the previous comment
This should now use \Drupal::time() since we're changing it here anyway. Changing it to inject the dependencies would be out of scope IMO, but this change should be fine.
Comment #13
BerdirCopy & paste of my comment in #2669802-50: Add a content entity form which allows to set revisions
Based on a short discussion in IRC with @catch, I provided another reason why a setting would make sense to me: We can add that any time in 8.x, we could even default it to TRUE (enforce setting) for new node types as long as we force it to FALSE in an update function for existing ones.
That allows sites that want to enforce this to do it now, and we can still see if we want to remove that setting again in 9.x and enforce it (while still allowing form alters or so to change it I suppose). Maybe those examples that I have in mind (like fixing a typo in the default revision while other changes are being worked on in forward/draft revisions or translation related things) will not longer be valid when we have improved UI's, workspaces and so on (Where users don't have to chose between creating a revision or not but between saving and saving as draft/other workflow state or something).
Comment #14
catchI'd be +1 to a setting, defaulting to on everywhere.
I think nearly all the cases Berdir brings up could at minimum be solved by creating a new revision and deleting the previous revision. Just doing this would be preferable to overwriting an individual revision since at least then we've reduced one code path (the specific code path which caused untold problems in 7.x).
Comment #15
seanBI agree that site builders at least should have a choice to enable the checkbox for authors. Not sure about the default setting? Maybe UX people can comment on that.
Comment #16
yoroy CreditAttribution: yoroy at Roy Scholten commentedAre we talking node form only or "everywhere" and if the latter, what does that mean? :)
Comment #17
seanBIt would be nice if we have a consistent UX for all revisionable entity types. For now I think it's just node and block content in core.
Comment #18
catch@yoroy so we'd add a setting, probably at the bundle or entity level, which controls whether the checkbox is shown. The idea being we add a setting for site builders in return for losing a checkbox on the node form. In 9.x we could remove both UIs altogether but this lets us improve the defaults with the smallest amount of change for existing sites.
Comment #20
yoroy CreditAttribution: yoroy at Roy Scholten commentedI agree that this is more of a site builder task to implement what's probably a *business* decision (about governance, compliance etc.) of whether to expose revision checkboxes to content authors. I think the default should be "on" so that it provides a kind of safety net for content changes.
Comment #21
geek-merlinIf i get it right the consensus here is (#13):
> We could add another setting to the node type to control if the [create new revision] setting should be enforced or not?
Setting title accordingly.
Also we have other related issues about (see related):
* Should the "revision log" field be provided
* Should (Add new revision | Revision log) be available on node-create or only on edit
(We can reasonably assume that "show on create but not on edit" does not make sense.
My feeling is that rather than splitting this into 2^n issues, let's handle this here "once and for all"(TM).
Comment #22
timmillwoodSounds like a plan, thanks @axel.rutz
Comment #23
geek-merlinSo when we want to configure
* Should the "revision log" field be provided
* Should (Add new revision | Revision log) be available on node-create or only on edit
...and we have these means of configuring:
* node type form
* form mode fields
* permissions
...i'd propose to do it like this:
* Make Override if a revision is created for node type foo a permission (which prevents the Add new revision checkbox)
* Make Add new revision and Revision log fields configurable per form-display. This opens the possibility to have them on one form mode and not the other.
* Make Show 'Add new revision' and 'Revision log' also on node create (not only on node edit) form" a setting per node type
Comment #24
geek-merlinOh, even more related issues...
Comment #25
BerdirWe already changed a while ago to not show the revision on node create, that's not up for discussion. A setting simply doesn't make sense because a new entity is always a new revision. In the past the setting was shown but was not relevant.
We currently already have a permission to control if the checkbox can be changed or not, that's administer nodes. While splitting that up would be useful, I don't think it belongs in this issue.
IMHO, this is really just about introducing a setting whether the new revision checkbox should not be visible at all, even for users with that permission. I disagree that trying to do multiple things here will make it easier to get it done, usually those kind of issues get stuck in discussions forever.
Comment #26
timmillwoodI think on the content type edit form (
/admin/structure/types/manage/article
), maybe under "publishing options" we first remove the "Create new revision" checkbox. Then add checkboxes for "allow content authors to choose if a new revision is created", "allow content authors to add a revision log"The create new revision checkbox should never show up on a new node form, because a new node will always be a new revision, but I think the revision log field should be shown on new and existing nodes.
Comment #27
Berdircrosspost
Comment #29
mlncn CreditAttribution: mlncn at Agaric for Drutopia, National Institute for Children's Health Quality, Teachers with GUTS commentedThe contrib solution to the original request (remove the checkbox) is Hide Revision Field: https://www.drupal.org/project/hide_revision_field
Its respectable usage statistics, despite being harder to find than this issue, indicates interest in removing this clutter from the authoring experience.
+1 to always doing revisions and hiding the log message textarea by default (or even letting contrib add it back)
Comment #31
matsbla CreditAttribution: matsbla commentedI created this issue #2978701: Replace the revision log message with a comment field. I'm not sure if this is a solution for this issue, but if revision log messages were a comment field site builders could at least decide what comment fields are mandatory or if all fields in the revision log will be hidden. So it will give site builders a lot of possibilities to configure the behavior they want.
Comment #33
seanBLet's make sure this is consistently solved for all revisionable entity types.
Comment #34
PanchoThe fact that a D8-only contrib module has more than thousand installs points to this being a major UI annoyance or, as the contrib maintainer says, "noise."
Full ACK.
Comment #36
chr.fritschWhat about making that "revision log" configurable by form display?
Comment #38
jonathanshawI love the idea in principle, but we need to handle its relationship with the "Create new revision" checkbox.
Comment #39
chr.fritschDo we really have a relation?
So what we could create is an extra field "Create new revision" that appears on all the form displays, next to "Revision log message".
In that case, the site builders have the maximum freedom.
As an alternative, we could create an extra field "Revision information" that combines the checkbox and the log message.
Comment #40
jonathanshawIf per #26 we persist in having a checkbox to "allow content authors to choose if a new revision is created" then
1. we should only show/enable the revision log field if they check that
2. we would likely want to place the revision log immediately under that checkbox
Extra fields don't have settings so with extra fields along we wouldn't have the ability for the sitebuilder to force the creation of new revisions but allow the editor to give a log message, or for the sitebuilder to allow the editor to choose whether a revision is created but not allow the editor to give a log message?
How about either:
A: Create depends on log
1) Create a bundle setting "Always create new revision"
2) Make the revision log form display configurable as you suggested in #36
3) If the setting "Always create new revision" is false, then create a new revision only if there is a log message
B: Use a widget
This is how the contrib module does it.
Comment #42
playful CreditAttribution: playful commentedIs there any update on this? I have recently created a site that allows users to register and post job announcements. On the job content type edit page I have unchecked the box to create a new revision, and this successfully removes that field from the create new node form. But the revision field remains on the edit node form, and it seems impossible to remove. That is a field that my users do not need to see and it seems crazy this wouldn't be configurable by the site builder.
There are configurable permissions to delete revisions, revert revisions, and view revisions... Why not simply make a permission for user roles to create revisions? When unchecked for a certain user role, the revision field would not display on node add/edit forms for the content type.
Comment #45
manuel.adanAlso, revision log field weight is hardcoded and cannot be altered via hook_form_alter due to another issue #3056053: Not possible to change weight of entity form field widget in hook_form_alter().
Comment #51
lauriiiLooks like something has changed and the "Create new revision" is now visible even for users who don't have the administer nodes permission. Filed issue for that: #3384520: "Create new revision" is overridable regardless of permissions.