Store latest vid in ENTITY_field_data and unlock views fields/relationships.

Created on 10 January 2024, 5 months ago

In this idea I refer to node, but it does apply to any revisionable entity type. Let's say I want these features for my vanilla /admin/content page:

  • Add a "Latest revision" relationship.
  • Add a field like "Has newer draft"

These are really hard to code. I know they are not impossible, but put in a very simplistic way they require a subquery that limits node_field_revision to rows that match nid and max vid.

What would completely change this situation is if node_field_data should have a latest_revision column. Then a views handlers will just join on node_field_data.latest_revision = node_revision_data.vid, which is a very slight varation on what JoinPluginBase does by default. And in the case of a "Has draft" then it's just 'real field' => 'latest_revision'.

What is the problem to solve?

At the moment if you want to add a "Has Draft" or "Latest revision link if relevant" field to an node view, it's very hard. These views fields, which are sometimes fundamental pieces of information that an editor wants to know, are not really possible to add to core unless we do entity loading in a views fields which isn't nice.

So at the moment we ship /admin/content view which can't surface latest draft data (if there is a published version). The solution we give to site builders to solve this problem is to replace the view completely with a view of revisions and then turn on aggregation and so on to get the same outcome. As a Drupal developer of nearly 20 years I don't really enjoy building these views as there is always some situations where i want to show a mix of draft fields and published fields on the one row (ie content from two separate revisions), which is pretty much impossible in many cases.

What happens in my experience is that the editor asks for this information to be surfaced in an administration page, but won't get this unless there is a vendor/developer who deeply understands how to rebuild the /admin/content view. In my situation today, we turned on workflow for an entity and then were faced with a fairly complex view (Groups module views can get gnarly) that we would need to rebuild.

Who is this for?

Site builders who are delivering features for editors.

Result: what will be the outcome?

If someone is building a view and searching for a "has draft" field, or "latest reivsion" relationship, they will find it.

How can we know the desired result is achieved

I have a problem here because I don't understand why i can never find this in the issue queue. But i've been on projects where we rebuidl the admin page for the editors, and I find these sorts of views loathsome at the point where I turn on aggregation.

✨ Feature request
Status

Closed: duplicate

Component

Idea

Created by

πŸ‡¦πŸ‡ΊAustralia sime Canberra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024