From 03559a8869606a9c2e660fa5f488c3e719d42054 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 30 Jan 2025 16:22:16 +1300 Subject: [PATCH] ENH Take advantage of new functionality in Versioned Avoids duplicated code to do what Versioned now lets you do. --- src/ArchiveAdmin.php | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/ArchiveAdmin.php b/src/ArchiveAdmin.php index 167def0..977df3d 100644 --- a/src/ArchiveAdmin.php +++ b/src/ArchiveAdmin.php @@ -138,31 +138,10 @@ public static function createArchiveGridField($title, $class) $config->addComponent(new GridFieldRestoreAction); $config->addComponent(new GridField_ActionMenu); - $singleton = singleton($class); - $list = $singleton->get(); - $baseTable = $singleton->baseTable(); - - $list = $list - ->setDataQueryParam('Versioned.mode', 'latest_versions'); - // Join a temporary alias BaseTable_Draft, renaming this on execution to BaseTable - // See Versioned::augmentSQL() For reference on this alias - $draftTable = $baseTable . '_Draft'; - $list = $list - ->leftJoin( - $draftTable, - "\"{$baseTable}\".\"ID\" = \"{$draftTable}\".\"ID\"" - ); - - if ($singleton->hasStages()) { - $liveTable = $baseTable . '_Live'; - $list = $list->leftJoin( - $liveTable, - "\"{$baseTable}\".\"ID\" = \"{$liveTable}\".\"ID\"" - ); - } - - $list = $list->where("\"{$draftTable}\".\"ID\" IS NULL"); - $list = $list->sort('LastEdited DESC'); + // Include "on live only" records because they won't appear in GridFields and + // other admin areas - so this may be the only way content authors can know that + // content is in a bad state. + $list = Versioned::getRemovedOnDraft($class)->sort('LastEdited DESC'); $field = GridField::create( $title,