From 3c983f9b51d05160e773fd9ce5615a067cd87418 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 28 Dec 2021 09:03:59 -0500 Subject: [PATCH] Fix issue where adding a new page was broken by commit b47297fd4adafcd6f1b12e943380e3f796793b7b --- wire/core/Pages.php | 2 -- wire/core/PagesEditor.php | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 93581d49..afc7bacc 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -1891,12 +1891,10 @@ class Pages extends Wire { if(empty($options)) return $this->wire(new Page()); - $id = isset($options['id']) && $options['id'] > 0 ? (int) $options['id'] : null; $options = $this->editor()->newPageOptions($options); $template = isset($options['template']) ? $options['template'] : null; $parent = isset($options['parent']) ? $options['parent'] : null; $class = empty($options['pageClass']) ? 'Page' : $options['pageClass']; - if($id !== null) $options['id'] = $id; unset($options['template'], $options['parent'], $options['pageClass']); diff --git a/wire/core/PagesEditor.php b/wire/core/PagesEditor.php index a2778084..f8f6c11f 100644 --- a/wire/core/PagesEditor.php +++ b/wire/core/PagesEditor.php @@ -1873,7 +1873,11 @@ class PagesEditor extends Wire { if($template) $options['template'] = $template; if($class) $options['pageClass'] = $class; - unset($options['id']); // just in case it was there + if(isset($options['id']) && ctype_digit("$options[id]") && (int) $options['id'] > 0) { + $options['id'] = (int) $options['id']; + } else { + unset($options['id']); + } return $options; }