diff --git a/wire/modules/PagePermissions.module b/wire/modules/PagePermissions.module index 90ad1b53..3fe359ce 100644 --- a/wire/modules/PagePermissions.module +++ b/wire/modules/PagePermissions.module @@ -783,7 +783,8 @@ class PagePermissions extends WireData implements Module { $page = $event->object; $user = $this->wire('user'); $addable = false; - $_ADDABLE = false; // if we really mean it + $addPage = null; + $_ADDABLE = false; // if we really mean it (as in, do not perform secondary checks) $superuser = $user->isSuperuser(); if($page->template->noChildren) { @@ -808,7 +809,8 @@ class PagePermissions extends WireData implements Module { // check if a $page is provided as the first argument for additional access checking if($addable) { $addPage = $event->arguments(0); - if($addPage && $addPage instanceof Page && $addPage->template && $page->template) { + if(!$addPage || !$addPage instanceof Page || !$addPage->id) $addPage = null; + if($addPage && $addPage->template && $page->template) { if(count($page->template->childTemplates) && !in_array($addPage->template->id, $page->template->childTemplates)) { $addable = false; } @@ -816,8 +818,8 @@ class PagePermissions extends WireData implements Module { } // check additional permissions if in multi-language environment - if($addable && !$_ADDABLE && $this->wire('languages')) { - if(!$this->hasPageEditLangDefault($user, $page) || !$this->hasPageEditLangNone($user, $page)) { + if($addable && !$_ADDABLE && $addPage && $this->wire('languages')) { + if(!$this->hasPageEditLangDefault($user, $addPage) || !$this->hasPageEditLangNone($user, $addPage)) { // if user can't edit default language, or can't edit non-multi-language fields, then deny add access $addable = false; }