From e274f69634755a732d195b769c649e3e6df3373a Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 22 Oct 2013 15:37:01 +0200 Subject: [PATCH] Notice->getParent function fixes NoResultException was the wrong choice in this case, because it was not a DB_DataObject instance that performed the search, but a static call to the Notice class. --- classes/Notice.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 1569590ba8..5a363f2775 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2530,19 +2530,15 @@ class Notice extends Managed_DataObject return $groups; } - protected $_parent = -1; + protected $_parent = -1; // local object cache public function getParent() { - if (empty($this->reply_to)) { - // Should this also be NoResultException? I don't think so. - throw new Exception('Notice has no parent'); - } elseif ($this->_parent === -1) { // local object cache + if (!empty($this->reply_to) && $this->_parent === -1) { $this->_parent = Notice::getKV('id', $this->reply_to); } - if (!($this->_parent instanceof Notice)) { - throw new NoResultException($this->_parent); + throw new ServerException('Notice has no parent'); } return $this->_parent; }