Commit 629cbede authored by mmn's avatar mmn

Dangerous non-dynamic profile fetching in Notice

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.
parent c99d4edd
......@@ -141,14 +141,14 @@ class Notice extends Managed_DataObject
const GROUP_SCOPE = 4;
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)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment