Skip to content

Commit

Permalink
ENH Don't emit deprecation warnings for unavoidable API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Aug 13, 2024
1 parent 81bfa84 commit 37080ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion code/BatchActions/CMSBatchAction_Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'));
}
}
7 changes: 4 additions & 3 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion code/Model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 37080ab

Please sign in to comment.