From 0e5428b78beaaa228709b7771a908e094907f922 Mon Sep 17 00:00:00 2001 From: Sabina Talipova <87288324+sabina-talipova@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:44:36 +1300 Subject: [PATCH] API Remove deprecated code (#2800) --- .upgrade.yml | 2 - _legacy/GraphQL/ReadOneResolver.php | 32 ------- code/Controllers/CMSMain.php | 74 +--------------- code/Model/SiteTree.php | 45 +--------- code/Model/SiteTreeFileExtension.php | 35 -------- .../SiteTreeFileFormFactoryExtension.php | 50 ----------- code/Model/SiteTreeFolderExtension.php | 88 ------------------- code/Model/VirtualPage.php | 25 ------ .../SiteTreeFileExtension_description.ss | 27 ------ tests/php/Controllers/CMSMainTest.php | 37 -------- tests/php/Model/SiteTreeTest.php | 17 +--- 11 files changed, 4 insertions(+), 428 deletions(-) delete mode 100644 _legacy/GraphQL/ReadOneResolver.php delete mode 100644 code/Model/SiteTreeFileExtension.php delete mode 100644 code/Model/SiteTreeFileFormFactoryExtension.php delete mode 100644 code/Model/SiteTreeFolderExtension.php delete mode 100644 templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss diff --git a/.upgrade.yml b/.upgrade.yml index d59203ba..f068e1d0 100644 --- a/.upgrade.yml +++ b/.upgrade.yml @@ -39,8 +39,6 @@ mappings: RedirectorPage_Controller: SilverStripe\CMS\Model\RedirectorPageController SiteTree: SilverStripe\CMS\Model\SiteTree SiteTreeExtension: SilverStripe\CMS\Model\SiteTreeExtension - SiteTreeFileExtension: SilverStripe\CMS\Model\SiteTreeFileExtension - SiteTreeFolderExtension: SilverStripe\CMS\Model\SiteTreeFolderExtension SiteTreeLinkTracking: SilverStripe\CMS\Model\SiteTreeLinkTracking SiteTreeLinkTracking_Parser: SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser VirtualPage: SilverStripe\CMS\Model\VirtualPage diff --git a/_legacy/GraphQL/ReadOneResolver.php b/_legacy/GraphQL/ReadOneResolver.php deleted file mode 100644 index 1acb276a..00000000 --- a/_legacy/GraphQL/ReadOneResolver.php +++ /dev/null @@ -1,32 +0,0 @@ -formatField('ID'); - $id = $args['filter'][$idKey]['eq']; - $readOne = Injector::inst()->createWithArgs(ReadOne::class, ['Page']); - unset($args['filter']); - $args[$idKey] = $id; - return $readOne->resolve($obj, $args, $context, $info); - } -} diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index 58b72c8f..155d7e9f 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -2,7 +2,6 @@ namespace SilverStripe\CMS\Controllers; -use SilverStripe\Dev\Deprecation; use InvalidArgumentException; use Psr\SimpleCache\CacheInterface; use SilverStripe\Admin\AdminRootController; @@ -198,7 +197,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr Requirements::css('silverstripe/cms: client/dist/styles/bundle.css'); Requirements::customCSS($this->generatePageIconsCss(), self::PAGE_ICONS_ID); - Requirements::add_i18n_javascript('silverstripe/cms: client/lang', false, true); + Requirements::add_i18n_javascript('silverstripe/cms: client/lang', false); CMSBatchActionHandler::register('restore', CMSBatchAction_Restore::class); CMSBatchActionHandler::register('archive', CMSBatchAction_Archive::class); @@ -2148,77 +2147,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return $this->batchactions()->batchActionList(); } - /** - * @deprecated 4.12.0 Use custom logic instead - */ - public function publishall(HTTPRequest $request): HTTPResponse - { - Deprecation::notice('4.12.0', 'Use custom logic instead'); - if (!Permission::check('ADMIN')) { - return Security::permissionFailure($this); - } - - Environment::increaseTimeLimitTo(); - Environment::increaseMemoryLimitTo(); - - $response = ""; - - if (isset($this->requestParams['confirm'])) { - // Protect against CSRF on destructive action - if (!SecurityToken::inst()->checkRequest($request)) { - $this->httpError(400); - } - - $start = 0; - $pages = SiteTree::get()->limit("$start,30"); - $count = 0; - while ($pages) { - /** @var SiteTree $page */ - foreach ($pages as $page) { - if ($page && !$page->canPublish()) { - return Security::permissionFailure($this); - } - - $page->publishRecursive(); - $page->destroy(); - unset($page); - $count++; - $response .= "
' . $publishAllDescription . '
- '; - } - - return HTTPResponse::create()->setBody($response); - } - /** * Restore a completely deleted page from the SiteTree_versions table. */ diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 2e701f87..1ab94186 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -25,7 +25,6 @@ use SilverStripe\Core\Manifest\ModuleResource; 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; @@ -651,11 +650,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi */ public function PreviewLink($action = null) { - if ($this->hasMethod('alternatePreviewLink')) { - Deprecation::notice('5.0', 'Use updatePreviewLink or override PreviewLink method'); - return $this->alternatePreviewLink($action); - } - $link = $this->AbsoluteLink($action); $this->extend('updatePreviewLink', $link, $action); return $link; @@ -2754,35 +2748,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi return $allowedChildren; } - /** - * @deprecated 4.12.0 Use creatableChildPages() instead - * - * Gets a list of the page types that can be created under this specific page - * - * @return array - */ - public function creatableChildren() - { - Deprecation::notice('4.12.0', 'Use creatableChildPages() instead'); - // Build the list of candidate children - $cache = SiteTree::singleton()->getCreatableChildrenCache(); - $cacheKey = $this->generateChildrenCacheKey(Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0); - $children = $cache->get($cacheKey, []); - if (!$children || !isset($children[$this->ID])) { - $children[$this->ID] = []; - $candidates = static::page_type_classes(); - foreach ($candidates as $childClass) { - $child = singleton($childClass); - if ($child->canCreate(null, ['Parent' => $this])) { - $children[$this->ID][$childClass] = $child->i18n_singular_name(); - } - } - $cache->set($cacheKey, $children); - } - - return $children[$this->ID]; - } - /** * * Gets a list of the page types that can be created under this specific page, including font icons @@ -3031,14 +2996,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi // If we have a class of "{$ClassName}Controller" then we found our controller if (class_exists($candidate = sprintf('%sController', $class))) { return $candidate; - } elseif (class_exists($candidate = sprintf('%s_Controller', $class))) { - // Support the legacy underscored filename, but raise a deprecation notice - Deprecation::notice( - '5.0', - 'Underscored controller class names are deprecated. Use "MyController" instead of "My_Controller".', - Deprecation::SCOPE_GLOBAL - ); - return $candidate; } elseif (is_array($namespaceMap)) { foreach ($namespaceMap as $pageNamespace => $controllerNamespace) { if (strpos($class, $pageNamespace) !== 0) { @@ -3302,7 +3259,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi } /** - * Cache key for creatableChildren() method + * Cache key for creatableChildPages() method * * @param int $memberID * @return string diff --git a/code/Model/SiteTreeFileExtension.php b/code/Model/SiteTreeFileExtension.php deleted file mode 100644 index 5cbd7d53..00000000 --- a/code/Model/SiteTreeFileExtension.php +++ /dev/null @@ -1,35 +0,0 @@ - 'HTMLFragment' - ]; - - /** - * Generate an HTML list which provides links to where a file is used. - * - * @return string - */ - public function __construct() - { - Deprecation::notice('4.2.0', 'Use FileLinkTracking instead', Deprecation::SCOPE_CLASS); - } - - public function BackLinkHTMLList() - { - $viewer = SSViewer::create(['type' => 'Includes', self::class . '_description']); - return $viewer->process($this->owner); - } -} diff --git a/code/Model/SiteTreeFileFormFactoryExtension.php b/code/Model/SiteTreeFileFormFactoryExtension.php deleted file mode 100644 index 59773030..00000000 --- a/code/Model/SiteTreeFileFormFactoryExtension.php +++ /dev/null @@ -1,50 +0,0 @@ -fieldByName('Editor'); - if (!$tabset) { - return; - } - - $usedOnField = UsedOnTable::create('UsedOnTableReplacement'); - $usedOnField->setRecord($context['Record']); - - // Add field to new tab - /** @var Tab $tab */ - $tab = Tab::create('Usage', _t(__CLASS__ . '.USAGE', 'Usage'), $usedOnField); - $tabset->push($tab); - } -} diff --git a/code/Model/SiteTreeFolderExtension.php b/code/Model/SiteTreeFolderExtension.php deleted file mode 100644 index 08f53f9e..00000000 --- a/code/Model/SiteTreeFolderExtension.php +++ /dev/null @@ -1,88 +0,0 @@ -column('LinkedID'); - - // Get all classes that aren't folder - $fileClasses = array_diff_key( - ClassInfo::subclassesFor(File::class) ?? [], - ClassInfo::subclassesFor(Folder::class) - ); - - // Search on a class-by-class basis - $classes = ClassInfo::subclassesFor(SiteTree::class); - - $schema = DataObject::getSchema(); - foreach ($classes as $className) { - // Build query based on all direct has_ones on this class - $hasOnes = Config::inst()->get($className, 'has_one', Config::UNINHERITED); - if (empty($hasOnes)) { - continue; - } - $where = []; - $columns = []; - foreach ($hasOnes as $relName => $joinClass) { - if (in_array($joinClass, $fileClasses ?? [])) { - $column = $relName . 'ID'; - $columns[] = $column; - $quotedColumn = $schema->sqlColumnForField($className, $column); - $where[] = "{$quotedColumn} > 0"; - } - } - - // Get all records with any file ID in the searched columns - $recordsArray = DataList::create($className)->whereAny($where)->toArray(); - $records = ArrayList::create($recordsArray); - foreach ($columns as $column) { - $usedFiles = array_unique(array_merge($usedFiles, $records->column($column))); - } - } - - // Create filter based on class and id - $classFilter = sprintf( - "(\"File\".\"ClassName\" IN (%s))", - implode(", ", Convert::raw2sql($fileClasses, true)) - ); - if ($usedFiles) { - return "\"File\".\"ID\" NOT IN (" . implode(', ', $usedFiles) . ") AND $classFilter"; - } else { - return $classFilter; - } - } -} diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 9d0573c2..991ddb29 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -4,7 +4,6 @@ namespace SilverStripe\CMS\Model; use Page; use SilverStripe\Core\Convert; -use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\ReadonlyTransformation; @@ -360,30 +359,6 @@ class VirtualPage extends Page return $result; } - /** - * @deprecated 4.2.0 Will be removed without equivalent functionality to replace it - */ - public function updateImageTracking() - { - Deprecation::notice('4.2.0', 'Will be removed without equivalent functionality to replace it'); - - // Doesn't work on unsaved records - if (!$this->isInDB()) { - return; - } - - // Remove CopyContentFrom() from the cache - unset($this->components['CopyContentFrom']); - - // Update ImageTracking - $copyContentFrom = $this->CopyContentFrom(); - if (!$copyContentFrom || !$copyContentFrom->isInDB()) { - return; - } - - $this->FileTracking()->setByIDList($copyContentFrom->FileTracking()->column('ID')); - } - public function CMSTreeClasses() { $parentClass = sprintf( diff --git a/templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss b/templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss deleted file mode 100644 index 44b5ac86..00000000 --- a/templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss +++ /dev/null @@ -1,27 +0,0 @@ -<% if $BackLinkTracking %> -<%t SilverStripe\CMS\Model\SiteTreeFileExtension.TITLE_INDEX '#' %> | -<%t SilverStripe\CMS\Model\SiteTreeFileExtension.TITLE_USED_ON 'Used on' %> | -<%t SilverStripe\CMS\Model\SiteTreeFileExtension.TITLE_TYPE 'Type' %> | -
---|---|---|
$Pos | -$MenuTitle | -- $i18n_singular_name - <% if $isPublished %> - Published - <% else %> - Draft - <% end_if %> - | -