From: Evan Prodromou Date: Mon, 8 Aug 2011 16:01:39 +0000 (-0400) Subject: Pass correct notice id to Memcached_DataObject::listGet() in getFaves() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ac268773bf917e3463856b5971c9843fb6a24cf8;p=quix0rs-gnu-social.git Pass correct notice id to Memcached_DataObject::listGet() in getFaves() --- diff --git a/classes/Notice.php b/classes/Notice.php index d39aea6c22..122c3c6299 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2547,7 +2547,7 @@ class Notice extends Memcached_DataObject } } - protected $_faves = -1; + protected $_faves; /** * All faves of this notice @@ -2557,15 +2557,15 @@ class Notice extends Memcached_DataObject function getFaves() { - if ($this->_faves != -1) { + if (isset($this->_faves) && is_array($this->_faves)) { return $this->_faves; } - $faveMap = Memcached_DataObject::listGet('Fave', 'notice_id', array($noticeId)); - $this->_faves = $faveMap[$noticeId]; + $faveMap = Memcached_DataObject::listGet('Fave', 'notice_id', array($this->id)); + $this->_faves = $faveMap[$this->id]; return $this->_faves; } - function _setFaves($faves) + function _setFaves(&$faves) { $this->_faves = $faves; } @@ -2574,6 +2574,14 @@ class Notice extends Memcached_DataObject { $ids = self::_idsOf($notices); $faveMap = Memcached_DataObject::listGet('Fave', 'notice_id', $ids); + $cnt = 0; + $faved = array(); + foreach ($faveMap as $id => $faves) { + $cnt += count($faves); + if (count($faves) > 0) { + $faved[] = $id; + } + } foreach ($notices as $notice) { $notice->_setFaves($faveMap[$notice->id]); }