Skip to content

Commit

Permalink
FIX Ensure unstaged versioned objects can be previewed.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed May 11, 2022
1 parent 3a990c9 commit 83104da
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion code/Controllers/SilverStripeNavigatorItem_Unversioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,24 @@ public function getTitle()
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.
*
Expand Down

0 comments on commit 83104da

Please sign in to comment.