From 626333a59eb0fc6728e5e16f65a67030e95bc22a Mon Sep 17 00:00:00 2001 From: abjectio Date: Wed, 14 Oct 2015 18:50:39 +0200 Subject: [PATCH] geParent() method will fail if the parent notice does not exist in the notice table. See https://quitter.no/notice/709400 --- classes/Notice.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/classes/Notice.php b/classes/Notice.php index 1b6edb4cd3..78ee18a980 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2775,10 +2775,24 @@ class Notice extends Managed_DataObject public function getParent() { + $reply_to_id = NULL; + if (empty($this->reply_to)) { throw new NoParentNoticeException($this); } - return self::getByID($this->reply_to); + + //The reply_to ID in the table Notice could exist with a number + //however, the replied to notice might not exist in the database. + //Thus we need to catch the exception and throw the NoParentNoticeException else + //the timeline will not display correctly. + try { + $reply_to_id = self::getByID($this->reply_to); + } catch(Exception e$){ + throw new NoParentNoticeException($this); + } + + + return $reply_to_id; } /** -- 2.39.5