diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 86ce8ab3..51221e3a 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -1339,8 +1339,6 @@ protected function saveParents($pages_id, $numChildren, $level = 0) { $query->bindValue(':pages_id', $pages_id, PDO::PARAM_INT); $query->execute(); - if(!$numChildren) return true; - $insertSql = ''; $id = $pages_id; $cnt = 0; @@ -1362,6 +1360,8 @@ protected function saveParents($pages_id, $numChildren, $level = 0) { $sql = "INSERT INTO pages_parents (pages_id, parents_id) VALUES" . rtrim($insertSql, ","); $database->exec($sql); } + + if(!$numChildren) return true; // find all children of $pages_id that themselves have children $sql = "SELECT pages.id, COUNT(children.id) AS numChildren " . @@ -1591,6 +1591,10 @@ public function ___clone(Page $page, Page $parent = null, $recursive = true, $op foreach($page->template->fieldgroup as $field) { $page->get($field->name); } + + $oldStatus = $page->status; + $page->status = $page->status | Page::statusSystemOverride; + $page->status = 1; // clone in memory $copy = clone $page; @@ -1618,6 +1622,8 @@ public function ___clone(Page $page, Page $parent = null, $recursive = true, $op $this->cloning = true; $options['ignoreFamily'] = true; // skip family checks during clone $this->save($copy, $options); + $copy->status = $oldStatus; + $copy->save(); } catch(Exception $e) { $this->cloning = false; throw $e; diff --git a/wire/modules/Process/ProcessPageClone.module b/wire/modules/Process/ProcessPageClone.module index 68cdfbcd..2f311499 100644 --- a/wire/modules/Process/ProcessPageClone.module +++ b/wire/modules/Process/ProcessPageClone.module @@ -113,7 +113,6 @@ class ProcessPageClone extends Process { public function hasPermission(Page $page) { $user = $this->user; - if($page->is(Page::statusSystem) || $page->is(Page::statusSystemID)) return false; if($page->parent->template->noChildren) return false; if($page->template->noParents) return false;