diff --git a/code/Controllers/LeftAndMainBatchActionsExtension.php b/code/Controllers/LeftAndMainBatchActionsExtension.php index 5e6294219b..837b783f28 100644 --- a/code/Controllers/LeftAndMainBatchActionsExtension.php +++ b/code/Controllers/LeftAndMainBatchActionsExtension.php @@ -11,7 +11,7 @@ */ class LeftAndMainBatchActionsExtension extends Extension { - public function updateBatchActionsForm(&$form) + protected function updateBatchActionsForm(&$form) { $cmsMain = singleton(CMSMain::class); $form->Fields()->insertAfter('Action', $cmsMain->BatchActionParameters()); diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 8838e49c1a..ab7b41f303 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -873,7 +873,7 @@ public function InSection($sectionName) * @param SiteTree $original * @param bool $doWrite */ - public function onBeforeDuplicate($original, $doWrite) + protected function onBeforeDuplicate($original, $doWrite) { $this->Sort = 0; } @@ -1756,7 +1756,7 @@ public function syncLinkTracking() $this->extend('augmentSyncLinkTracking'); } - public function onBeforeDelete() + protected function onBeforeDelete() { parent::onBeforeDelete(); @@ -1768,7 +1768,7 @@ public function onBeforeDelete() } } - public function onAfterDelete() + protected function onAfterDelete() { $this->updateDependentPages(); parent::onAfterDelete(); @@ -2625,7 +2625,7 @@ public function getCMSActions() return $actions; } - public function onAfterPublish() + protected function onAfterPublish() { // Force live sort order to match stage sort order $sql = sprintf( @@ -2642,7 +2642,7 @@ public function onAfterPublish() /** * Update draft dependant pages */ - public function onAfterRevertToLive() + protected function onAfterRevertToLive() { // Use an alias to get the updates made by $this->publish /** @var SiteTree $stageSelf */ diff --git a/code/Model/SiteTreeExtension.php b/code/Model/SiteTreeExtension.php index e1b73a5c6e..33c2793fff 100644 --- a/code/Model/SiteTreeExtension.php +++ b/code/Model/SiteTreeExtension.php @@ -19,7 +19,7 @@ abstract class SiteTreeExtension extends DataExtension * * @param SiteTree &$original The current Live SiteTree record prior to publish */ - public function onBeforePublish(&$original) + protected function onBeforePublish(&$original) { } @@ -28,14 +28,14 @@ public function onBeforePublish(&$original) * * @param SiteTree &$original The current Live SiteTree record prior to publish */ - public function onAfterPublish(&$original) + protected function onAfterPublish(&$original) { } /** * Hook called before the page's {@link Versioned::doUnpublish()} action is completed */ - public function onBeforeUnpublish() + protected function onBeforeUnpublish() { } @@ -43,7 +43,7 @@ public function onBeforeUnpublish() /** * Hook called after the page's {@link SiteTree::doUnpublish()} action is completed */ - public function onAfterUnpublish() + protected function onAfterUnpublish() { } diff --git a/code/Model/SiteTreeLinkTracking.php b/code/Model/SiteTreeLinkTracking.php index 8adb8aa9d6..bfc26976a7 100644 --- a/code/Model/SiteTreeLinkTracking.php +++ b/code/Model/SiteTreeLinkTracking.php @@ -85,7 +85,7 @@ public function setParser(SiteTreeLinkTracking_Parser $parser = null) return $this; } - public function onBeforeWrite() + protected function onBeforeWrite() { // Trigger link tracking (unless this would also be triggered by FileLinkTracking) if (!$this->owner->hasExtension(FileLinkTracking::class)) { @@ -107,7 +107,7 @@ public function syncLinkTracking() /** * Find HTMLText fields on {@link owner} to scrape for links that need tracking */ - public function augmentSyncLinkTracking() + protected function augmentSyncLinkTracking() { // If owner is versioned, skip tracking on live if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) { @@ -143,7 +143,7 @@ public function augmentSyncLinkTracking() $this->owner->LinkTracking()->setByIDList($linkedPages); } - public function onAfterDelete() + protected function onAfterDelete() { // If owner is versioned, skip tracking on live if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) { @@ -215,7 +215,7 @@ protected function toggleElementClass(DOMElement $domReference, $class, $toggle) } } - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { if (!$this->owner->config()->get('show_sitetree_link_tracking')) { $fields->removeByName('LinkTracking'); diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 99bb784fd6..09a3c3acba 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -285,7 +285,7 @@ public function getCMSFields() return parent::getCMSFields(); } - public function onBeforeWrite() + protected function onBeforeWrite() { $this->refreshFromCopied(); parent::onBeforeWrite(); diff --git a/tests/behat/src/AdditionalAnchorPageExtension.php b/tests/behat/src/AdditionalAnchorPageExtension.php index 9cfe01405c..db7d4251a9 100644 --- a/tests/behat/src/AdditionalAnchorPageExtension.php +++ b/tests/behat/src/AdditionalAnchorPageExtension.php @@ -6,7 +6,7 @@ class AdditionalAnchorPageExtension extends Extension { - public function updateAnchorsOnPage(array &$anchors): void + protected function updateAnchorsOnPage(array &$anchors): void { $anchors[] = 'dataobject-anchor'; } diff --git a/tests/php/Model/RedirectorPageTest_RedirectExtension.php b/tests/php/Model/RedirectorPageTest_RedirectExtension.php index 6af5e2af23..2ece7d5e24 100644 --- a/tests/php/Model/RedirectorPageTest_RedirectExtension.php +++ b/tests/php/Model/RedirectorPageTest_RedirectExtension.php @@ -7,7 +7,7 @@ class RedirectorPageTest_RedirectExtension extends Extension implements TestOnly { - public function onBeforeInit() + protected function onBeforeInit() { $this->owner->redirect('/foo'); } diff --git a/tests/php/Model/SiteTreeBacklinksTest_DOD.php b/tests/php/Model/SiteTreeBacklinksTest_DOD.php index 629abcc32f..8f2e86fb36 100644 --- a/tests/php/Model/SiteTreeBacklinksTest_DOD.php +++ b/tests/php/Model/SiteTreeBacklinksTest_DOD.php @@ -13,7 +13,7 @@ class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly 'ExtraContent' => 'HTMLText', ]; - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent")); } diff --git a/tests/php/Model/SiteTreeLinkTracking_Extension.php b/tests/php/Model/SiteTreeLinkTracking_Extension.php index ab745a1ac3..b05913d2b4 100644 --- a/tests/php/Model/SiteTreeLinkTracking_Extension.php +++ b/tests/php/Model/SiteTreeLinkTracking_Extension.php @@ -7,7 +7,7 @@ class SiteTreeLinkTracking_Extension extends DataExtension implements TestOnly { - public function updateAnchorsOnPage(&$anchors) + protected function updateAnchorsOnPage(&$anchors) { array_push( $anchors, diff --git a/tests/php/Model/SiteTreeTest.php b/tests/php/Model/SiteTreeTest.php index 7eb44ec1f2..ce09e7cb4e 100644 --- a/tests/php/Model/SiteTreeTest.php +++ b/tests/php/Model/SiteTreeTest.php @@ -2153,8 +2153,10 @@ public function testOnAfterRevertToLive() $obj->Content = 'Link to Page'; $obj->write(); - //Test that method doesn't throw exception + // Test that method doesn't throw exception $this->expectNotToPerformAssertions(); - $page->onAfterRevertToLive(); + $method = new ReflectionMethod(SiteTree::class, 'onAfterRevertToLive'); + $method->setAccessible(true); + $method->invoke($page); } } diff --git a/tests/php/Model/SiteTreeTest_Extension.php b/tests/php/Model/SiteTreeTest_Extension.php index e1b85c6a72..5fa0cdd84d 100644 --- a/tests/php/Model/SiteTreeTest_Extension.php +++ b/tests/php/Model/SiteTreeTest_Extension.php @@ -7,7 +7,7 @@ class SiteTreeTest_Extension extends DataExtension implements TestOnly { - public function augmentValidURLSegment() + protected function augmentValidURLSegment() { return false; }