X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2FProfile.php;h=f635ee470df8a2f596055a5b5729d5808264afd6;hb=874f1db38980bd5a748b2a70159bd70ef7798c08;hp=c23fc1fed2083add4d9dc2cc09e4b74ff13b6f50;hpb=9208c94b2927a67d2ec4db5766952b0066f14fbc;p=quix0rs-gnu-social.git diff --git a/classes/Profile.php b/classes/Profile.php index c23fc1fed2..f635ee470d 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1,7 +1,7 @@ tagger = $this->id; + $ids = array(); + + $keypart = sprintf('profile:lists:%d', $this->id); + + $idstr = self::cacheGet($keypart); - if (($auth_user instanceof User || $auth_user instanceof Profile) && - $auth_user->id === $this->id) { - // no condition, get both private and public tags + if ($idstr !== false) { + $ids = explode(',', $idstr); } else { - $tags->private = false; - } + $list = new Profile_list(); + $list->selectAdd(); + $list->selectAdd('id'); + $list->tagger = $this->id; + $list->selectAdd('id as "cursor"'); - $tags->selectAdd('id as "cursor"'); + if ($since_id>0) { + $list->whereAdd('id > '.$since_id); + } - if ($since_id>0) { - $tags->whereAdd('id > '.$since_id); - } + if ($max_id>0) { + $list->whereAdd('id <= '.$max_id); + } - if ($max_id>0) { - $tags->whereAdd('id <= '.$max_id); - } + if($offset>=0 && !is_null($limit)) { + $list->limit($offset, $limit); + } - if($offset>=0 && !is_null($limit)) { - $tags->limit($offset, $limit); + $list->orderBy('id DESC'); + + if ($list->find()) { + while ($list->fetch()) { + $ids[] = $list->id; + } + } + + self::cacheSet($keypart, implode(',', $ids)); } - $tags->orderBy('id DESC'); - $tags->find(); + $showPrivate = (($auth_user instanceof User || + $auth_user instanceof Profile) && + $auth_user->id === $this->id); - return $tags; + $lists = array(); + + foreach ($ids as $id) { + $list = Profile_list::staticGet('id', $id); + if (!empty($list) && + ($showPrivate || !$list->private)) { + + if (!isset($list->cursor)) { + $list->cursor = $list->id; + } + + $lists[] = $list; + } + } + + return new ArrayWrapper($lists); } function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0) @@ -1210,13 +1245,8 @@ class Profile extends Memcached_DataObject if (!empty($user)) { $uri = $user->uri; - } else { - // return OMB profile if any - $remote = Remote_profile::staticGet('id', $this->id); - if (!empty($remote)) { - $uri = $remote->uri; - } } + Event::handle('EndGetProfileUri', array($this, &$uri)); } @@ -1261,11 +1291,6 @@ class Profile extends Memcached_DataObject $user = User::staticGet('uri', $uri); if (!empty($user)) { $profile = $user->getProfile(); - } else { - $remote_profile = Remote_profile::staticGet('uri', $uri); - if (!empty($remote_profile)) { - $profile = Profile::staticGet('id', $remote_profile->profile_id); - } } Event::handle('EndGetProfileFromURI', array($uri, $profile)); } @@ -1324,41 +1349,20 @@ class Profile extends Memcached_DataObject return $profile; } - function getLists($showPrivate) - { - $ids = array(); - - $keypart = sprintf('profile:lists:%d', $this->id); - - $idstr = self::cacheGet($keypart); - - if ($idstr !== false) { - $ids = explode(',', $idstr); - } else { - $list = new Profile_list(); - $list->selectAdd(); - $list->selectAdd('id'); - $list->tagger = $this->id; - - if ($list->find()) { - while ($list->fetch()) { - $ids[] = $list->id; - } - } - - self::cacheSet($keypart, implode(',', $ids)); - } - - $lists = array(); - - foreach ($ids as $id) { - $list = Profile_list::staticGet('id', $id); - if (!empty($list) && - ($showPrivate || !$list->private)) { - $lists[] = $list; - } - } + /** + * Magic function called at serialize() time. + * + * We use this to drop a couple process-specific references + * from DB_DataObject which can cause trouble in future + * processes. + * + * @return array of variable names to include in serialization. + */ - return new ArrayWrapper($lists); + function __sleep() + { + $vars = parent::__sleep(); + $skip = array('_user'); + return array_diff($vars, $skip); } }