Skip to content

Commit

Permalink
Merge pull request #2819 from creative-commoners/pulls/4/deprecate-le…
Browse files Browse the repository at this point in the history
…gacy-tasks

API Deprecate legacy tasks
  • Loading branch information
Maxime Rainville authored Jan 17, 2023
2 parents b0fec18 + 75eae7f commit 5316767
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions code/Tasks/MigrateSiteTreeLinkingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\BuildTask;
use SilverStripe\Dev\Debug;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\Versioned\Versioned;

/**
* Updates legacy SiteTree link tracking into new polymorphic many_many relation.
* This should be done for any site upgrading to 4.2.0
*
* @deprecated 4.13.0 Will be removed without equivalent functionality to replace it
*/
class MigrateSiteTreeLinkingTask extends BuildTask
{
Expand All @@ -21,6 +24,15 @@ class MigrateSiteTreeLinkingTask extends BuildTask

protected $description = 'Updates legacy SiteTree link tracking into new polymorphic many_many relation';

public function __construct()
{
Deprecation::notice(
'4.13.0',
'Will be removed without equivalent functionality to replace it',
Deprecation::SCOPE_CLASS
);
}

public function run($request)
{
// Ensure legacy table exists
Expand Down
12 changes: 12 additions & 0 deletions code/Tasks/RemoveOrphanedPagesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\View\Requirements;
use SilverStripe\Dev\Deprecation;

/**
* Identify "orphaned" pages which point to a parent
Expand All @@ -36,6 +37,8 @@
* before and after orphan removal.
*
* @author Ingo Schommer (<firstname>@silverstripe.com), SilverStripe Ltd.
*
* @deprecated 4.13.0 Will be removed without equivalent functionality to replace it
*/
class RemoveOrphanedPagesTask extends Controller
{
Expand Down Expand Up @@ -65,6 +68,15 @@ class RemoveOrphanedPagesTask extends Controller

protected $orphanedSearchClass = SiteTree::class;

public function __construct()
{
Deprecation::notice(
'4.13.0',
'Will be removed without equivalent functionality to replace it',
Deprecation::SCOPE_CLASS
);
}

protected function init()
{
parent::init();
Expand Down
13 changes: 13 additions & 0 deletions code/Tasks/SiteTreeMaintenanceTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
use SilverStripe\Control\Controller;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
use SilverStripe\Dev\Deprecation;

/**
* @deprecated 4.13.0 Will be removed without equivalent functionality to replace it
*/
class SiteTreeMaintenanceTask extends Controller
{
private static $allowed_actions = [
'*' => 'ADMIN'
];

public function __construct()
{
Deprecation::notice(
'4.13.0',
'Will be removed without equivalent functionality to replace it',
Deprecation::SCOPE_CLASS
);
}

public function makelinksunique()
{
$table = DataObject::singleton(SiteTree::class)->baseTable();
Expand Down
4 changes: 4 additions & 0 deletions tests/php/Tasks/MigrateSiteTreeLinkingTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\Dev\Deprecation;

class MigrateSiteTreeLinkingTaskTest extends SapphireTest
{
Expand Down Expand Up @@ -34,6 +35,9 @@ public static function setUpBeforeClass(): void

protected function setUp(): void
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
parent::setUp();

// Manually bootstrap all Content blocks with soft coded IDs (raw sql to avoid save hooks)
Expand Down
4 changes: 4 additions & 0 deletions tests/php/Tasks/RemoveOrphanedPagesTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Dev\Deprecation;

/**
* <h2>Fixture tree</h2>
Expand Down Expand Up @@ -40,6 +41,9 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest

protected function setUp(): void
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
parent::setUp();

$parent1_published = $this->objFromFixture('Page', 'parent1_published');
Expand Down

0 comments on commit 5316767

Please sign in to comment.