diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index d02923814..9b8c7ce68 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -504,13 +504,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid */ public function duplicate($doWrite = true) { - $this->extend('onBeforeDuplicate', $page); $page = parent::duplicate(false); $page->Sort = 0; + $this->extend('onBeforeDuplicate', $page); + if($doWrite) { $page->write(); } $this->extend('onAfterDuplicate', $page); + return $page; }