Follow-up to #2674520: Add current revision filter to views

Problem/Motivation

The last issue added a table to track the latest revision of entities that are moderated. However, if you have pre-moderation entities they won't be in that table. That could lead to all sorts of I don't know what badness.

Proposed resolution

If it can be done efficiently, pre-populate the table when an entity bundle is first moderation-enabled.

If not, just track everything always, which will necessitate a single larger pre-populate command on install.

Remaining tasks

Decide on approach.
Implement.
Test.

User interface changes

None.

API changes

TBC.

Data model changes

TBC.

CommentFileSizeAuthor
#2 2701365-legacy-tracker.patch4.45 KBCrell

Comments

Crell created an issue. See original summary.

Crell’s picture

Status: Active » Needs review
StatusFileSize
new4.45 KB

So after some experimentation and consideration, I think this is fine. Turns out, WBM D7 didn't handle legacy content either. Also, nothing actually breaks for legacy content; it just doesn't show in latest-revision views, which is in practice probably not a big problem as you'd be building such a view for content that needs moderator attention. If it's unmoderated, and thus its default version is published, you wouldn't want it in that view anyway.

The only problem is if someone uses the views filter before the table has EVER been created, in which case you get an missing SQL table explosion. The attached patch fixes that. It's not the ideal approach but it works and I don't know of a better one.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/src/Plugin/views/filter/LatestRevision.php
@@ -74,6 +84,10 @@ class LatestRevision extends FilterPluginBase implements ContainerFactoryPluginI
+    if (!$this->connection->schema()->tableExists('workbench_revision_tracker')) {
+      return;
+    }
+

works for me, unless you want to add a quick line of documentation.

Crell’s picture

Title: Populate legacy entities in latest_revision tracker table » Handle not yet created revision tracker table
Status: Reviewed & tested by the community » Fixed

Added several quick lines of documentation and merged. Thanks, dawehner.

  • Crell committed 3803b75 on 8.x-1.x
    Issue #2701365 by Crell: Handle not-yet-created revision tracker table...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.