]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Throw exception if Local_group has no corresponding User_group
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 26 May 2015 11:14:26 +0000 (13:14 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 26 May 2015 11:14:26 +0000 (13:14 +0200)
classes/Local_group.php

index c0dcf02e4be3e86b7f5a14fe15cf1bd677575322..9e95102d8503753a034bc28ee9fd53da391436cd 100644 (file)
@@ -40,16 +40,19 @@ class Local_group extends Managed_DataObject
 
     public function getProfile()
     {
-        $group = $this->getGroup();
-        if (!$group instanceof User_group) {
-            return null;    // TODO: Throw exception when other code is ready
-        }
-        return $group->getProfile();
+        return $this->getGroup()->getProfile();
     }
 
     public function getGroup()
     {
-        return User_group::getKV('id', $this->group_id);
+        $group = new User_group();
+        $group->id = $this->group_id;
+        $group->find(true);
+        if (!$group instanceof User_group) {
+            common_log(LOG_ERR, 'User_group does not exist for Local_group: '.$this->group_id);
+            throw new NoResultException($group);
+        }
+        return $group;
     }
 
     function setNickname($nickname)