From 42aee9d303b75f0f7210222d190d1168a96feaa6 Mon Sep 17 00:00:00 2001
From: Guy Sartorelli <guy.sartorelli@silverstripe.com>
Date: Wed, 14 Aug 2024 10:34:08 +1200
Subject: [PATCH] FIX Use canDelete, not the now-deleted canArchive

---
 code/BatchActions/CMSBatchAction_Archive.php | 2 +-
 code/Controllers/CMSMain.php                 | 6 +++---
 code/Model/SiteTree.php                      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/code/BatchActions/CMSBatchAction_Archive.php b/code/BatchActions/CMSBatchAction_Archive.php
index 7520ffac6d..ccf989a8c7 100644
--- a/code/BatchActions/CMSBatchAction_Archive.php
+++ b/code/BatchActions/CMSBatchAction_Archive.php
@@ -27,6 +27,6 @@ public function run(SS_List $pages): HTTPResponse
 
     public function applicablePages($ids)
     {
-        return $this->applicablePagesHelper($ids, 'canArchive');
+        return $this->applicablePagesHelper($ids, 'canDelete');
     }
 }
diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php
index bbd3ada8cd..e7e923ef8c 100644
--- a/code/Controllers/CMSMain.php
+++ b/code/Controllers/CMSMain.php
@@ -1109,13 +1109,13 @@ private function buildListViewBreadcrumb(ArrayList $items, SiteTree $page): void
         // Find all ancestors of the provided page
         $ancestors = $page->getAncestors(true);
         $ancestors = array_reverse($ancestors->toArray() ?? []);
-        
+
         //turns the title and link of the breadcrumbs into template-friendly variables
         $params = array_filter([
             'view' => $this->getRequest()->getVar('view'),
             'q' => $this->getRequest()->getVar('q')
         ]);
-        
+
         foreach ($ancestors as $ancestor) {
             // Link back to the list view for the current ancestor
             $params['ParentID'] = $ancestor->ID;
@@ -1997,7 +1997,7 @@ public function archive(array $data, Form $form): HTTPResponse
         if (!$record || !$record->exists()) {
             throw new HTTPResponse_Exception("Bad record ID #$id", 404);
         }
-        if (!$record->canArchive()) {
+        if (!$record->canDelete()) {
             return Security::permissionFailure();
         }
 
diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php
index 41e2ded717..59a8b1b65f 100755
--- a/code/Model/SiteTree.php
+++ b/code/Model/SiteTree.php
@@ -2585,7 +2585,7 @@ public function getCMSActions()
         }
 
         // If a page is on any stage it can be archived
-        if (($isOnDraft || $isPublished) && $this->canArchive()) {
+        if (($isOnDraft || $isPublished) && $this->canDelete()) {
             $title = $isPublished
                 ? _t('SilverStripe\\CMS\\Controllers\\CMSMain.UNPUBLISH_AND_ARCHIVE', 'Unpublish and archive')
                 : _t('SilverStripe\\CMS\\Controllers\\CMSMain.ARCHIVE', 'Archive');