-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
The exact example of the stream output results in
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 266338320 bytes) in /shared/httpd/app/vendor/jsvrcek/ics/src/CalendarStream.php on line 79
$calendar->setEventsProvider(function () use ($events) {
$calendarEvents = [];
foreach ($events as $event) {
$calendarEvent = new CalendarEvent();
$calendarEvent->setStart(new \DateTime($event->beginning->toIso8601String()))
->setAllDay($event->date_only)
->setSummary($event->title)
->setDescription($event->description)
->setStatus($event->status_string)
->setUid($event->id);
if ($event->end) {
$calendarEvent->setEnd(new \DateTime($event->end->toIso8601String()));
}
if ($event->url) {
$calendarEvent->setUrl($event->url);
}
if ($event->lat && $event->lng) {
$geo = new Geo();
$geo->setLatitude($event->lat);
$geo->setLongitude($event->lng);
$calendarEvent->setGeo($geo);
}
if ($event->location) {
$location = new \Jsvrcek\ICS\Model\Description\Location();
$location->setName($event->location);
$calendarEvent->addLocation($location);
}
$image = $event->image(true);
if ($image) {
$calendarEvent->setImage([
'VALUE' => 'URL',
'URI' => $image,
]);
}
$calendarEvents[] = $calendarEvent;
}
return $calendarEvents;
});
//setup exporter
$calendarExport = new CalendarExport(new CalendarStream, new Formatter());
$calendarExport->addCalendar($calendar);
//set exporter to send items directly to output instead of storing in memory
$calendarExport->getStreamObject()->setDoImmediateOutput(true);
//output .ics formatted text
echo $calendarExport->getStream();Even commenting out the $calendarExport->getStreamObject()->setDoImmediateOutput(true); part does not help.
PHP 8.2
Metadata
Metadata
Assignees
Labels
No labels