From: Mikael Nordfeldth Date: Tue, 26 May 2015 11:14:26 +0000 (+0200) Subject: Throw exception if Local_group has no corresponding User_group X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6b717a6a6917bd024431f8d1e0835325e0194421;p=quix0rs-gnu-social.git Throw exception if Local_group has no corresponding User_group --- diff --git a/classes/Local_group.php b/classes/Local_group.php index c0dcf02e4b..9e95102d85 100644 --- a/classes/Local_group.php +++ b/classes/Local_group.php @@ -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)