From fab59a5f4b527d5bc2756815d480d8253a355409 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 25 Feb 2022 08:37:00 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#1533 --- wire/core/PagesEditor.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wire/core/PagesEditor.php b/wire/core/PagesEditor.php index be41fed1..ade51e34 100644 --- a/wire/core/PagesEditor.php +++ b/wire/core/PagesEditor.php @@ -1876,11 +1876,15 @@ class PagesEditor extends Wire { if($template) $options['template'] = $template; if($class) $options['pageClass'] = $class; - if(isset($options['id']) && ctype_digit("$options[id]") && (int) $options['id'] > 0) { - $options['id'] = (int) $options['id']; - if($parent && "$options[id]" === "$parent") unset($options['parent']); - } else { - unset($options['id']); + if(isset($options['id'])) { + if(ctype_digit("$options[id]") && (int) $options['id'] > 0) { + $options['id'] = (int) $options['id']; + if($parent && "$options[id]" === "$parent") unset($options['parent']); + } else if(((int) $options['id']) === -1) { + $options['id'] = (int) $options['id']; // special case allowed for access control tests + } else { + unset($options['id']); + } } return $options;