From 83104da3294c09f3d4038b5de94c5ef0b04b3eb3 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 6 May 2022 14:30:01 +1200 Subject: [PATCH] FIX Ensure unstaged versioned objects can be previewed. --- .../SilverStripeNavigatorItem_Unversioned.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/Controllers/SilverStripeNavigatorItem_Unversioned.php b/code/Controllers/SilverStripeNavigatorItem_Unversioned.php index bc532efc..2ee5f4e3 100644 --- a/code/Controllers/SilverStripeNavigatorItem_Unversioned.php +++ b/code/Controllers/SilverStripeNavigatorItem_Unversioned.php @@ -40,12 +40,24 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem public function canView($member = null) { return ( - !$this->getRecord()->hasExtension(Versioned::class) + $this->recordIsUnversioned() && $this->showUnversionedLink() && $this->getLink() ); } + private function recordIsUnversioned(): bool + { + $record = $this->getRecord(); + // If the record has the Versioned extension, it can be considered unversioned + // for the purposes of this class if it has no stages and is not archived. + if ($record->hasExtension(Versioned::class)) { + return (!$record->hasStages()) && !$this->isArchived(); + } + // Completely unversioned. + return true; + } + /** * True if the record is configured to display this item. *