mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 00:06:55 +02:00
Update the $pages->add() method to pull a fresh copy of the $page from the database after it has been added. This helps with some API usages where returned $page may have not been fully initialized in some cases.
This commit is contained in:
@@ -102,6 +102,11 @@ class PagesEditor extends Wire {
|
|||||||
unset($values['title']);
|
unset($values['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($values['status'])) {
|
||||||
|
$page->status = $values['status'];
|
||||||
|
unset($values['status']);
|
||||||
|
}
|
||||||
|
|
||||||
// save page before setting $values just in case any fieldtypes
|
// save page before setting $values just in case any fieldtypes
|
||||||
// require the page to have an ID already (like file-based)
|
// require the page to have an ID already (like file-based)
|
||||||
if(!$this->pages->save($page)) throw new WireException($exceptionMessage);
|
if(!$this->pages->save($page)) throw new WireException($exceptionMessage);
|
||||||
@@ -113,6 +118,15 @@ class PagesEditor extends Wire {
|
|||||||
$this->pages->save($page);
|
$this->pages->save($page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get a fresh copy of the page
|
||||||
|
if($page->id) {
|
||||||
|
$of = $this->pages->outputFormatting;
|
||||||
|
if($of) $this->pages->setOutputFormatting(false);
|
||||||
|
$p = $this->pages->getById($page->id, $template, $page->parent_id);
|
||||||
|
if($p->id) $page = $p;
|
||||||
|
if($of) $this->pages->setOutputFormatting(true);
|
||||||
|
}
|
||||||
|
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user