]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Dangerous non-dynamic profile fetching in Notice
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 3 Jun 2014 10:22:07 +0000 (12:22 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 3 Jun 2014 10:22:07 +0000 (12:22 +0200)
For a Notice object with multiple results, ->getProfile() would ALWAYS
return the first profile in the list. For example our "popular notices"
stream ended up believing all notices were made by the same profile.

classes/Notice.php

index f055096c33f4f22c7cc2c4c5cc5ea6465487c33e..73e05912ac2bb4356de052f201650f1ea8b13559 100644 (file)
@@ -141,14 +141,14 @@ class Notice extends Managed_DataObject
     const GROUP_SCOPE     = 4;
     const FOLLOWER_SCOPE  = 8;
 
-    protected $_profile = -1;
+    protected $_profile = array();
     
     public function getProfile()
     {
-        if ($this->_profile === -1) {
+        if (!isset($this->_profile[$this->profile_id])) {
             $this->_setProfile(Profile::getKV('id', $this->profile_id));
         }
-        return $this->_profile;
+        return $this->_profile[$this->profile_id];
     }
     
     public function _setProfile(Profile $profile=null)
@@ -156,7 +156,7 @@ class Notice extends Managed_DataObject
         if (!$profile instanceof Profile) {
             throw new NoProfileException($this->profile_id);
         }
-        $this->_profile = $profile;
+        $this->_profile[$this->profile_id] = $profile;
     }
 
     function delete($useWhere=false)