From 416f55ad03ffe84a3c93717c0416a64e254e090c Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 28 Nov 2022 17:49:50 +1300 Subject: [PATCH] API Stop using deprecated API --- src/Extensions/SiteTreeSubsites.php | 6 ++++-- src/Model/Subsite.php | 2 +- tests/php/LeftAndMainSubsitesTest.php | 6 +++--- tests/php/SubsiteTest.php | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Extensions/SiteTreeSubsites.php b/src/Extensions/SiteTreeSubsites.php index 324ce730..15f50ae6 100644 --- a/src/Extensions/SiteTreeSubsites.php +++ b/src/Extensions/SiteTreeSubsites.php @@ -245,6 +245,7 @@ public function onBeforeDuplicate() */ public function duplicateToSubsite($subsiteID = null, $includeChildren = false) { + /** @var SiteTree|SiteTreeSubsites */ $clone = $this->owner->duplicateToSubsitePrep($subsiteID, $includeChildren); $clone->invokeWithExtensions('onBeforeDuplicateToSubsite', $this->owner); @@ -267,12 +268,13 @@ public function duplicateToSubsite($subsiteID = null, $includeChildren = false) * It may be that some relations are not diostinct to sub site so can stay * whereas others may need to be duplicated * - * @deprecated 2.2.0 Use the "cascade_duplicates" config API instead + * This was originally deprecated - Use the "cascade_duplicates" config API instead + * Ideally this would be re-deprecated + * * @param SiteTree $originalPage */ public function duplicateSubsiteRelations($originalPage) { - Deprecation::notice('2.2.0', 'Use the "cascade_duplicates" config API instead'); $thisClass = $originalPage->ClassName; $relations = Config::inst()->get($thisClass, 'duplicate_to_subsite_relations'); diff --git a/src/Model/Subsite.php b/src/Model/Subsite.php index fb819fc2..25ec6204 100644 --- a/src/Model/Subsite.php +++ b/src/Model/Subsite.php @@ -448,7 +448,7 @@ public static function accessible_sites( // Rationalise member arguments if (!$member) { - $member = Member::currentUser(); + $member = Security::getCurrentUser(); } if (!$member) { return new ArrayList(); diff --git a/tests/php/LeftAndMainSubsitesTest.php b/tests/php/LeftAndMainSubsitesTest.php index ea60db5a..c54a20ee 100644 --- a/tests/php/LeftAndMainSubsitesTest.php +++ b/tests/php/LeftAndMainSubsitesTest.php @@ -38,19 +38,19 @@ public function testSectionSites() $cmsmain = singleton(CMSMain::class); $subsites = $cmsmain->sectionSites(true, 'Main site', $member); - $this->assertDOSEquals([ + $this->assertListEquals([ ['Title' => 'Subsite1 Template'] ], $subsites, 'Lists member-accessible sites for the accessible controller.'); $assetadmin = singleton(AssetAdmin::class); $subsites = $assetadmin->sectionSites(true, 'Main site', $member); - $this->assertDOSEquals([], $subsites, 'Does not list any sites for forbidden controller.'); + $this->assertListEquals([], $subsites, 'Does not list any sites for forbidden controller.'); $member = $this->objFromFixture(Member::class, 'editor'); $cmsmain = singleton(CMSMain::class); $subsites = $cmsmain->sectionSites(true, 'Main site', $member); - $this->assertDOSContains([ + $this->assertListContains([ ['Title' => 'Main site'] ], $subsites, 'Includes the main site for members who can access all sites.'); } diff --git a/tests/php/SubsiteTest.php b/tests/php/SubsiteTest.php index d75650d7..bcd5085d 100644 --- a/tests/php/SubsiteTest.php +++ b/tests/php/SubsiteTest.php @@ -350,7 +350,7 @@ public function domainProtocolProvider() public function testAllSites() { $subsites = Subsite::all_sites(); - $this->assertDOSEquals([ + $this->assertListEquals([ ['Title' => 'Main site'], ['Title' => 'Template'], ['Title' => 'Subsite1 Template'], @@ -370,7 +370,7 @@ public function testAllAccessibleSites() $member = $this->objFromFixture(Member::class, 'subsite1member'); $subsites = Subsite::all_accessible_sites(true, 'Main site', $member); - $this->assertDOSEquals([ + $this->assertListEquals([ ['Title' => 'Subsite1 Template'] ], $subsites, 'Lists member-accessible sites.'); } @@ -471,7 +471,7 @@ public function testDuplicateSubsite() $page1 = new Page(); $page1->Title = 'MyAwesomePage'; $page1->write(); - $page1->doPublish(); + $page1->publishRecursive(); $this->assertEquals($page1->SubsiteID, $subsite1->ID); // duplicate @@ -481,7 +481,7 @@ public function testDuplicateSubsite() $page2 = DataObject::get_one('Page', "\"Title\" = 'MyAwesomePage'"); $page2->Title = 'MyNewAwesomePage'; $page2->write(); - $page2->doPublish(); + $page2->publishRecursive(); // check change & check change has not affected subiste1 $subsite1->activate();