- $ids = self::stream($user_id, $offset, self::MAX_NOTICES, $since_id, $max_id, $own);
-
- // Do a bulk lookup for the first $limit items
- // Fast path when nothing's deleted.
- $firstChunk = array_slice($ids, 0, $limit);
- $notices = Notice::getStreamByIds($firstChunk);
-
- $wanted = count($firstChunk); // raw entry count in the inbox up to our $limit
- if ($notices->N >= $wanted) {
- return $notices;
- }
-
- // There were deleted notices, we'll need to look for more.
- assert($notices instanceof ArrayWrapper);
- $items = $notices->_items;
- $remainder = array_slice($ids, $limit);
-
- while (count($items) < $wanted && count($remainder) > 0) {
- $notice = Notice::staticGet(array_shift($remainder));
- if ($notice) {
- $items[] = $notice;
- } else {
- }
- }
- return new ArrayWrapper($items);