Show if there is a published revision when looking at the latest draft

So technically this is already done, albeit very, very subtly, with the tabs: View will be unselected at the left, and Latest version will be shown highlighted, when you are looking at the latest revision. But that’s really subtle. So just as i add a “This (content type) is not yet viewable by the public. Please complete and publish it soon!” banner on unpublished nodes, i want a similar banner, “This (content type) draft has not yet been published. An older version is published; please complete and publish this latest draft soon!”

Here’s one solution:

… but it can’t really be that complicated, can it?

OK, apparently it really can be that complicated, because this has not, and may never, get into core:

Track the latest_revision and latest_revision_translation_affected ID in the entity data table for revisionable entity types

Can it really be that bad? I searched the Drupal core issue queue for “latest revision”. Conclusion: It’s that bad.

Slightly related, this seems to be for use in Views: Provide link to latest revision of moderated entity. And it’s just plain confusing, even for developers working with core APIs, let alone content editors: Entity query needs to clarify what ‘current revision’ means.

A latestRevision() method was added to \Drupal\Core\Entity\Query\QueryInterface:

Allow entity query to query the latest revision

(Unfortunately, it proved a bit of a performance issue).

And really basic stuff that needs to understand the latest version doesn’t… like quick edit not working when content moderation is in use until this is done: Add ability to use Quick Edit to the latest_revision route.

But anyway there seems to be basic awareness that the user experience leaves a bit to be desired:

[Policy, No patch] Overhaul the entity revision terminology in UI text … old and sort of abandoned though, ends with webchick acknowledging that we need to see what makes sense to people trying to use content moderation first.

Document the scope and purpose of pending revisions

Set as current revision is misleading with content moderation enabled.

Clarify concepts (and implementation) around reverting revisions and publishing forward revisions

A huge issue to Provide a better UX for creating, editing & managing draft revisions has apparently been abandoned since the Content Moderation core module came to be, but many of the improvements it was discussing did not make it into that core module.

John Pitcairn had a good set of UI recommendations there.

This makes sense: Change “create new revision” check box (defaults to TRUE) to “Overwrite existing revision” (defaults to FALSE). Oh. But it’s something that makes sense that was proposed ten years ago. Whoops.

Looks like Drupal is slowly trying to move in the direction of hardcoding less, and doing everything off of transitions, which is good news for me and my approach with Workflow buttons— but then, on the other hand, this issue here is not yet committed—Dynamically provide action plugins for every moderation state change—and the spinoff module just hardcodes published and unpublished.

This too: Implement a generic revision access API.

Here’s one that speaks to me:

Codify mechanism to set a forward revision as the default revision

I’m basically trying to work around it with the recommended configuration for workflow transitions and states to work with Workflow buttons: create workflow states for each desired combination of published or not and whether that is the default revision, and create an explicit transition for each. For instance, instead of allowing to go from published to draft, and that can either mean forking with a new ‘forward revision’ draft while the current version stays published or it could mean unpublishing and the edited (if at all) version is now the default version, we need to be explicit: Add an ‘Unpublished’ status that gets configured to be the default revision when changed to that state, and create an ‘Unpublish’ transition for getting to that state from the Published state. This is a separate transition from one that could be called “Save draft, leave current published” that is the ‘Published’ to ‘Draft’ transition.

(Well the initial need is what i’m working around; the conversation went more to the likely need for Add a revision_parent field to revisionable entities), which i’m just trying not to be so complicated as to need that.