If a user edits a node (or similar) using Quick Edit, those changes are based on the current DEFAULT revision. That may not be the LATEST revision. If not, then we end up with a new revision in (according to my testing) the default state that is more recent than the previous latest revision. That is, we've forked the forward revisions path. Since we do not track the parentage of forward revisions that means the perviously latest revision is now orphaned and unavailable, except through manually accessing it on the Revisions tab. We also do not support merging, so either way one line or the other is SOL. This is a problem.
One possible solution I discussed with one of our designers, Ashley Cyborski, is that we want to add a "view latest draft" tab anyway. So, enable quick edit on that tab instead and *disable it* on the normal view tab. I do not know how feasible that is. Anyone else know?
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | 2635890-44.patch | 3.98 KB | dawehner |
| #37 | interdiff.txt | 703 bytes | dawehner |
| #37 | 2635890-37.patch | 4 KB | dawehner |
| #33 | interdiff.txt | 4.32 KB | dawehner |
| #33 | 2635890-33.patch | 4 KB | dawehner |
Comments
Comment #2
Crell commentedComment #3
Crell commentedAdding link.
Comment #4
Crell commentedComment #5
dawehnerAdding that tab is certainly easier than rendering a different revision for a different user, at least for now.
Comment #6
Crell commentedHow easy is it to change which page has Quick Edit enabled on it? If we have /node/{node}/view and /node/{node}/latest, we want Quick Edit to show up only on the second, not the first, but only when there is a forward revision.
Comment #7
dawehnerAfaik its possible on every page which have proper rendered fields, so its there automatically.
Comment #8
Crell commentedSure, but we want to *block* Quick Edit on some pages, because you'd be editing the wrong thing.
... And probably in views, too, because those also show the wrong thing. Erf. :-(
Comment #9
dawehnerWait, did you just said that quickedit is a problematic concept?
Comment #10
Crell commentedI did. :-) If you QuickEdit from the DEFAULT revision, rather than LATEST revision, Bad Things Happen(tm). But the whole point of QuickEdit is to start from the visible revision. So... Erf.
Comment #11
dawehnerWell, maybe you just made clear that quickedit is a problematic concept for sites with an editorial workflow. Well, I'm sooo sad about that.
Comment #12
Crell commentedSarcastic dawehner is sarcastic...
Still, we'll need a way to disable it. Maybe we can get Wim's input?
Comment #13
Crell commentedComment #14
wim leersThe root cause of the problem is not Quick Edit. It is our extremely ill-defined model of revisions.
Quick Edit does only one thing: it allows you to in-place edit the visible fields of an entity. Period. (The visible fields are the non-empty fields.)
The values for fields are determined by which revision of an entity is loaded. And this is where we enter the
painful realmwild west of revisions in Drupal (8 or otherwise). The revision that is displayed is indeed the "default" revision. Which revision is the default does not depend on anything: not on time, nor the branch (we don't even have the concept of different branches of an entity), nor the current user, nor anything else.Now, this is already quite bad. But to make it worse, the handling of is not implemented in a generic way. In fact, it only exists for
Node. So, Quick Edit also had to special-case this:And as you can tell, a new revision is created only if
NodeType::isNewRevision()returnsTRUE, which is the (misnamed) method thatGets whether a new revision should be created by default..Conclusion: for all entity types except
Node, and forNodealso if the bundle (NodeType) defaults to "no new revision by default", Quick Edit will just edit the revision you see. Otherwise, it will create a new revision.The above means that as soon as you have a complex workflow, you need to make sure that you either:
Use
hook_entity_view_alter()to disable in-place editing for a specific entity by undoing whatquickedit_entity_view_alter()did (i.e. unset$build['#attributes']['data-quickedit-entity-id']), and add cacheability metadata if necessary to$build.Use
hook_entity_build_defaults_alter()to change$entityto represent a different revision than the default and again add cacheability metadata if necessary to$build. This one needs double-checking though, not 100% certain about it.Comment #15
Crell commentedThanks, Wim. Having worked with the revisions API (such as it is) for the last few weeks I completely agree that core is very incomplete here. Hopefully we can improve that in minor releases.
For the time being, we've discussed just disabling Quick Edit entirely for any Moderation-enabled bundle. It sounds from #14 like the best way to do that is via hook_entity_view_alter(), so let's give that a shot and see if that works. Just from a user-expectation standpoint, I think mixing Quick Edit and forward revisions is asking for trouble.
Comment #16
dawehnerSo yeah what about doing that until we find a better solution for it?
Comment #17
wim leersI don't agree with this. However, I do think that a lot of UX work is necessary to make it clear and easy to understand. And I think that solving that is identical to (or at least largely overlapping with, if not a subset of) making Workbench Moderation easy to understand.
I suspect you're working on Workbench Moderation MVP, which means the absolute minimum of making it easy to understand (i.e. across a site, for every piece of content that is being moderated or could be moderated, alther what is shown to make that crystal clear). From that POV, I agree.
Comment #18
moshe weitzman commentedA less heavy handed approach would be to disable quick edit for any entity that has a forward revision. Not sure how feasible that is.
Comment #19
wim leersShould be totally doable.
Comment #20
Crell commentedPossibly, but my concern there is that you can quick-edit a node, change the title or whatever, and then after you hit save... seemingly nothing happens, except that quick-edit no longer works. A new revision has been created in Draft, and you could go to the Edit tab to find it, but it's very non-obvious what's happening in that case.
Comment #21
moshe weitzman commentedFair enough ... When an entity has a forward revision, how about changing the pencil to a red pencil (or whatever). The title text would say why quick edit is unavailable. If a person clicks on the red pencil, you can go to the edit form for the forward revision or pop a modal with explanatory text and offer more possible destinations.
Comment #22
Crell commentedMaybe, but I have no idea how to do that. :-) Let's try to just disable it first, then we can iterate on better visuals.
Comment #23
dawehnerSo what about something like this.
Comment #24
wim leersYep, something like that :)
Comment #25
moshe weitzman commentedDrupal surgery!
Comment #26
Crell commentedLooks about right, but is there no way to do this without module_implements_alter? Generally speaking, module_implements_alter is a sign that you have other problems.
Comment #27
wim leersNo,
module_implements_alter()is just a sign you want to modify the modification another module is making.This is the biggest weakness of the hook system: it's designed to allow modules to alter things. When >1 module wants to alter the same thing, you end up in this situation: module hook invocation order matters.
If all hook implementations merely add things, there is no problem.
This is how Drupal's hook system is designed to work.
Comment #28
dawehnerWell, there is no difference from hooks vs. events here. Its more about the general idea of mutability.
On the other hand, the event system is a bit better here. This
module_implements_alter()code is basically the same as changing a weight in events, just crazy odd syntax.Comment #29
Crell commentedComment #30
wim leersIndeed.
Comment #31
Crell commentedCan we move this logic to a service? I'd rather have no hooks in the module that are more than a service call.
Also, the conditional may be simplified to a single method (either in that service or in the info service). There may even be a better method to use already to check that, or we just beef up isLatestRevision to make the isRevisionable() call unnecessary.
Comment #32
Crell commentedComment #33
dawehnerYeah, I just love your
Comment #37
dawehnerYou should not c&p anything.
Comment #41
wim leersYou may also want to fix #2362435: When viewing a revision, the Quick Edit, Edit, and Delete contextual link operations are available, but should not be, it's very closely related.
Comment #42
Crell commentedI think the bot hiccuped, so let's try again.
Comment #43
Crell commentedBot likes it but needs a reroll for the services file. Sorry, I broke it with another commit. :-(
Comment #44
dawehnerThere we go.
Comment #45
Crell commentedCommitted. Thanks, dawehner!
Comment #47
wim leersIt's , not >inline editing.