From 37080ab1d37ecf648bfdf3478ed5360c1388d9d5 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 14 Aug 2024 11:32:34 +1200 Subject: [PATCH] ENH Don't emit deprecation warnings for unavoidable API calls --- code/BatchActions/CMSBatchAction_Archive.php | 3 ++- code/Controllers/CMSMain.php | 7 ++++--- code/Model/SiteTree.php | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/code/BatchActions/CMSBatchAction_Archive.php b/code/BatchActions/CMSBatchAction_Archive.php index 7520ffac6d..fb19bd6aa8 100644 --- a/code/BatchActions/CMSBatchAction_Archive.php +++ b/code/BatchActions/CMSBatchAction_Archive.php @@ -5,6 +5,7 @@ use SilverStripe\ORM\SS_List; use SilverStripe\Admin\CMSBatchAction; use SilverStripe\Control\HTTPResponse; +use SilverStripe\Dev\Deprecation; /** * Delete items batch action. @@ -27,6 +28,6 @@ public function run(SS_List $pages): HTTPResponse public function applicablePages($ids) { - return $this->applicablePagesHelper($ids, 'canArchive'); + return Deprecation::withNoReplacement(fn() => $this->applicablePagesHelper($ids, 'canArchive')); } } diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index bbd3ada8cd..daadd8d679 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -29,6 +29,7 @@ use SilverStripe\Core\Environment; use SilverStripe\Core\Flushable; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\DateField; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldGroup; @@ -1109,13 +1110,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 +1998,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 (!Deprecation::withNoReplacement(fn() => $record->canArchive())) { return Security::permissionFailure(); } diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 5f7556d61d..cdd9990a7f 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -25,6 +25,7 @@ use SilverStripe\Core\Manifest\ModuleResourceLoader; use SilverStripe\Core\Manifest\VersionProvider; use SilverStripe\Core\Resettable; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CompositeField; use SilverStripe\Forms\DropdownField; @@ -2567,7 +2568,7 @@ public function getCMSActions() } // If a page is on any stage it can be archived - if (($isOnDraft || $isPublished) && $this->canArchive()) { + if (($isOnDraft || $isPublished) && Deprecation::withNoReplacement(fn() => $this->canArchive())) { $title = $isPublished ? _t('SilverStripe\\CMS\\Controllers\\CMSMain.UNPUBLISH_AND_ARCHIVE', 'Unpublish and archive') : _t('SilverStripe\\CMS\\Controllers\\CMSMain.ARCHIVE', 'Archive');