Throw exception when a Conversation is not found

This commit is contained in:
Mikael Nordfeldth 2015-05-26 13:11:08 +02:00
parent bb8d377b91
commit 925aacec1a
1 changed files with 7 additions and 1 deletions

View File

@ -108,7 +108,13 @@ class Conversation extends Managed_DataObject
static public function getUrlFromNotice(Notice $notice, $anchor=true) static public function getUrlFromNotice(Notice $notice, $anchor=true)
{ {
$conv = self::getKV('id', $notice->conversation); $conv = new Conversation();
$conv->id = $notice->conversation;
$conv->find(true);
if (!$conv instanceof Conversation) {
common_debug('Conversation does not exist for notice ID: '.$notice->id);
throw new NoResultException($conv);
}
return $conv->getUrl($anchor ? $notice->id : null); return $conv->getUrl($anchor ? $notice->id : null);
} }