mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Additional updates for processwire/processwire-issues#1814
This commit is contained in:
@@ -626,15 +626,24 @@ class PagesParents extends Wire {
|
|||||||
foreach($ids as $id) {
|
foreach($ids as $id) {
|
||||||
foreach($newParentIds as $parentId) {
|
foreach($newParentIds as $parentId) {
|
||||||
if($id === $parentId) continue;
|
if($id === $parentId) continue;
|
||||||
$inserts["$id,$parentId"] = array('pages_id' => $id, 'parents_id' => (int) $parentId);
|
$inserts[] = "$id,$parentId";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// redundancy to capture specific missing parent situations
|
||||||
|
foreach($newParent->parents() as $parent) {
|
||||||
|
if($parent->id < 2) continue;
|
||||||
|
$inserts[] = "$newParent->id,$parent->id";
|
||||||
|
if($parent->parent_id > 1) {
|
||||||
|
$grandParent = $parent->parent();
|
||||||
|
$inserts[] = "$parent->id,$grandParent->id";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($numChildren) {
|
// if page has children also add it to the inserts list
|
||||||
// if page has children also add it to the inserts list
|
if($numChildren) $inserts[] = "$page->id,$newParent->id";
|
||||||
$inserts["$page->id,$newParent->id"] = array('pages_id' => $page->id, 'parents_id' => $newParent->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// delete old parent IDs
|
||||||
if(count($oldParentIds) && count($ids)) {
|
if(count($oldParentIds) && count($ids)) {
|
||||||
$idStr = implode(',', $ids);
|
$idStr = implode(',', $ids);
|
||||||
$oldParentIds = $this->wire()->sanitizer->intArray($oldParentIds);
|
$oldParentIds = $this->wire()->sanitizer->intArray($oldParentIds);
|
||||||
@@ -649,8 +658,9 @@ class PagesParents extends Wire {
|
|||||||
$query = $database->prepare($sql);
|
$query = $database->prepare($sql);
|
||||||
|
|
||||||
foreach($inserts as $insert) {
|
foreach($inserts as $insert) {
|
||||||
$query->bindValue(':pages_id', $insert['pages_id'], \PDO::PARAM_INT);
|
list($id, $parentId) = explode(',', $insert, 2);
|
||||||
$query->bindValue(':parents_id', $insert['parents_id'], \PDO::PARAM_INT);
|
$query->bindValue(':pages_id', $id, \PDO::PARAM_INT);
|
||||||
|
$query->bindValue(':parents_id', $parentId, \PDO::PARAM_INT);
|
||||||
try {
|
try {
|
||||||
if($query->execute()) $numRows++;
|
if($query->execute()) $numRows++;
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
|
Reference in New Issue
Block a user