* eSync/Calendar: reading events in chunks of 100, to keep memory down for huge calendars

This commit is contained in:
Ralf Becker 2016-06-24 11:15:19 +02:00
parent 83948cc750
commit 67ffe04524

View File

@ -203,14 +203,21 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
);
$messagelist = array();
foreach ($this->calendar->search($filter) as $event)
// reading events in chunks of 100, to keep memory down for huge calendars
$num_rows = 100;
for($start=0; ($events = $this->calendar->search($filter+array(
'offset' => $start,
'num_rows' => $num_rows,
))); $start += $num_rows)
{
foreach ($events as $event)
{
if ($not_uids && in_array($event['uid'], $not_uids)) continue;
$messagelist[] = $this->StatMessage($id, $event);
// add virtual exceptions for recuring events too
// (we need to read event, as get_recurrence_exceptions need all infos!)
/* if ($event['recur_type'] != calendar_rrule::NONE)// && ($event = $this->calendar->read($event['id'],0,true,'server')))
/* if ($event['recur_type'] != calendar_rrule::NONE)// && ($event = $this->calendar->read($event['id'],0,true,'server')))
{
foreach($this->calendar->so->get_recurrence_exceptions($event,
@ -220,6 +227,9 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
}
}*/
}
if (count($events) < $num_rows) break;
}
//error_log(__METHOD__."($id, $cutoffdate, ".array2string($not_uids).") type=$type, user=$user returning ".count($messagelist)." messages ".function_backtrace());
return $messagelist;
}