]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notice->getParent function fixes
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 22 Oct 2013 13:37:01 +0000 (15:37 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 22 Oct 2013 13:37:19 +0000 (15:37 +0200)
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

index 1569590ba834df134eaa75256405aa2237074dd4..5a363f2775926b759f4064ac40e30db378868bff 100644 (file)
@@ -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;
     }