From c3b0401ee59e46e86674802ffe2b9aa867059233 Mon Sep 17 00:00:00 2001 From: Jake Bentvelzen Date: Wed, 14 Oct 2015 14:00:24 +1100 Subject: [PATCH] Fixed a bug where an error occurred when attempting to change the page type of 'Blog' --- code/model/Blog.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/model/Blog.php b/code/model/Blog.php index 9a8cabe..ba4bd7b 100644 --- a/code/model/Blog.php +++ b/code/model/Blog.php @@ -546,10 +546,13 @@ class Blog extends Page implements PermissionProvider { $group = $this->getUserGroup(); - foreach(array($this->Editors(), $this->Writers(), $this->Contributors()) as $levels) { - foreach($levels as $user) { - if(!$user->inGroup($group)) { - $user->Groups()->add($group); + // Must check if the method exists or else an error occurs when changing page type + if ($this->hasMethod('Editors')) { + foreach(array($this->Editors(), $this->Writers(), $this->Contributors()) as $levels) { + foreach($levels as $user) { + if(!$user->inGroup($group)) { + $user->Groups()->add($group); + } } } }