Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove check for statusSystemID and statusSystem in module ProcessPageClone #1258

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions wire/core/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 " .
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion wire/modules/Process/ProcessPageClone.module
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down