]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
$notice->getProfile will ALWAYS return a Profile
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 4 Jun 2014 22:07:04 +0000 (00:07 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 4 Jun 2014 22:07:04 +0000 (00:07 +0200)
otherwise it throws an exception

classes/Notice.php

index 931c561b0855a4cc073e9d8f8bb12b0a531a2942..4e5987faa931837536a0bcdd0186cf8fc8493509 100644 (file)
@@ -143,6 +143,10 @@ class Notice extends Managed_DataObject
 
     protected $_profile = array();
     
+    /**
+     * Will always return a profile, if anything fails it will
+     * (through _setProfile) throw a NoProfileException.
+     */
     public function getProfile()
     {
         if (!isset($this->_profile[$this->profile_id])) {
@@ -1317,19 +1321,17 @@ class Notice extends Managed_DataObject
             return array();
         }
 
-        $sender = Profile::getKV($this->profile_id);
+        $sender = $this->getProfile();
 
         $replied = array();
 
         // If it's a reply, save for the replied-to author
         try {
             $parent = $this->getParent();
-            $author = $parent->getProfile();
-            if ($author instanceof Profile) {
-                $this->saveReply($author->id);
-                $replied[$author->id] = 1;
-                self::blow('reply:stream:%d', $author->id);
-            }
+            $parentauthor = $parent->getProfile();
+            $this->saveReply($parentauthor->id);
+            $replied[$parentauthor->id] = 1;
+            self::blow('reply:stream:%d', $parentauthor->id);
         } catch (Exception $e) {
             // Not a reply, since it has no parent!
         }