function hasFave($notice)
{
- $cache = Cache::instance();
-
- // XXX: Kind of a hack.
-
- if (!empty($cache)) {
- // This is the stream of favorite notices, in rev chron
- // order. This forces it into cache.
-
- $ids = Fave::idStream($this->id, 0, CachingNoticeStream::CACHE_WINDOW);
-
- // If it's in the list, then it's a fave
-
- if (in_array($notice->id, $ids)) {
- return true;
- }
-
- // If we're not past the end of the cache window,
- // then the cache has all available faves, so this one
- // is not a fave.
-
- if (count($ids) < CachingNoticeStream::CACHE_WINDOW) {
- return false;
- }
-
- // Otherwise, cache doesn't have all faves;
- // fall through to the default
- }
-
$fave = Fave::pkeyGet(array('user_id' => $this->id,
'notice_id' => $notice->id));
return ((is_null($fave)) ? false : true);