Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x

This commit is contained in:
Brion Vibber 2010-04-01 11:09:45 -07:00
commit d844e6bde5

View File

@ -225,6 +225,36 @@ class Profile extends Memcached_DataObject
{
$notice = new Notice();
// Temporary hack until notice_profile_id_idx is updated
// to (profile_id, id) instead of (profile_id, created, id).
// It's been falling back to PRIMARY instead, which is really
// very inefficient for a profile that hasn't posted in a few
// months. Even though forcing the index will cause a filesort,
// it's usually going to be better.
if (common_config('db', 'type') == 'mysql') {
$index = '';
$query =
"select id from notice force index (notice_profile_id_idx) ".
"where profile_id=" . $notice->escape($this->id);
if ($since_id != 0) {
$query .= " and id > $since_id";
}
if ($max_id != 0) {
$query .= " and id < $max_id";
}
$query .= ' order by id DESC';
if (!is_null($offset)) {
$query .= " LIMIT $limit OFFSET $offset";
}
$notice->query($query);
} else {
$index = '';
$notice->profile_id = $this->id;
$notice->selectAdd();
@ -244,13 +274,14 @@ class Profile extends Memcached_DataObject
$notice->limit($offset, $limit);
}
$notice->find();
}
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
return $ids;
}