diff --git a/src/VersionedStateExtension.php b/src/VersionedStateExtension.php index 29edfa64..1de660c3 100644 --- a/src/VersionedStateExtension.php +++ b/src/VersionedStateExtension.php @@ -2,6 +2,7 @@ namespace SilverStripe\Versioned; +use SilverStripe\Admin\LeftAndMain; use SilverStripe\Control\Controller; use SilverStripe\Control\RequestHandler; use SilverStripe\Core\Extension; @@ -48,6 +49,11 @@ public function updateLink(&$link) return; } + // Don't touch Admin/CMS links + if (class_exists(LeftAndMain::class) && $this->getOwner() instanceof LeftAndMain) { + return; + } + // Decorate $link = Controller::join_links( $link, diff --git a/tests/php/VersionedStateExtensionTest.php b/tests/php/VersionedStateExtensionTest.php index 4c1217c7..ad91f7ae 100644 --- a/tests/php/VersionedStateExtensionTest.php +++ b/tests/php/VersionedStateExtensionTest.php @@ -2,6 +2,7 @@ namespace SilverStripe\Versioned\Tests; +use SilverStripe\Admin\LeftAndMain; use SilverStripe\Dev\SapphireTest; use SilverStripe\Versioned\Versioned; use SilverStripe\Versioned\VersionedStateExtension; @@ -61,4 +62,19 @@ public function testUpdateLinkRespectsQueryArgs() ->byID($obj1ID); $this->assertEquals('item/myobject/', $obj1Live->Link()); } + + public function testDontUpdateLeftAndMainLinks() + { + $controller = new LeftAndMain(); + + $liveClientConfig = $controller->getClientConfig(); + Versioned::set_stage(Versioned::DRAFT); + $stageClientConfig = $controller->getClientConfig(); + + $this->assertEquals( + $liveClientConfig, + $stageClientConfig, + 'LeftAndMain Client config should not be affected by versionned stage.' + ); + } }