use Notice::multiGet() for NoticeStream::getStreamByIds()

This commit is contained in:
Evan Prodromou 2011-07-14 12:03:33 -04:00
parent 42b11f862a
commit 9ab0a6f760

View File

@ -59,42 +59,6 @@ abstract class NoticeStream
static function getStreamByIds($ids) static function getStreamByIds($ids)
{ {
$cache = Cache::instance(); return Notice::multiGet('id', $ids);
if (!empty($cache)) {
$notices = array();
foreach ($ids as $id) {
$n = Notice::staticGet('id', $id);
if (!empty($n)) {
$notices[] = $n;
}
}
return new ArrayWrapper($notices);
} else {
$notice = new Notice();
if (empty($ids)) {
//if no IDs requested, just return the notice object
return $notice;
}
$notice->whereAdd('id in (' . implode(', ', $ids) . ')');
$notice->find();
$temp = array();
while ($notice->fetch()) {
$temp[$notice->id] = clone($notice);
}
$wrapped = array();
foreach ($ids as $id) {
if (array_key_exists($id, $temp)) {
$wrapped[] = $temp[$id];
}
}
return new ArrayWrapper($wrapped);
}
} }
} }