Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(caldav): duration handling in the event reader class #49066

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions apps/dav/lib/CalDAV/EventReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OCA\DAV\CalDAV;

use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use InvalidArgumentException;
Expand Down Expand Up @@ -109,7 +110,7 @@
unset($events[$key]);
}
}

// No base event was found. CalDAV does allow cases where only
// overridden instances are stored.
//
Expand Down Expand Up @@ -173,15 +174,17 @@
// evaluate if duration exists
// extract duration and calculate end date
elseif (isset($this->baseEvent->DURATION)) {
$this->baseEventDuration = $this->baseEvent->DURATION->getDateInterval();
$this->baseEventEndDate = ((clone $this->baseEventStartDate)->add($this->baseEventDuration));
$this->baseEventEndDate = DateTimeImmutable::createFromInterface($this->baseEventStartDate)
->add($this->baseEvent->DURATION->getDateInterval());

Check notice

Code scanning / Psalm

PossiblyUndefinedMethod Note

Method Sabre\VObject\Property::getDateInterval does not exist
$this->baseEventDuration = $this->baseEventEndDate->getTimestamp() - $this->baseEventStartDate->getTimestamp();
}
// evaluate if start date is floating
// set duration to 24 hours and calculate the end date
// according to the rfc any event without a end date or duration is a complete day
elseif ($this->baseEventStartDateFloating == true) {
$this->baseEventDuration = 86400;
$this->baseEventEndDate = ((clone $this->baseEventStartDate)->add($this->baseEventDuration));
$this->baseEventEndDate = DateTimeImmutable::createFromInterface($this->baseEventStartDate)
->setTimestamp($this->baseEventStartDate->getTimestamp() + $this->baseEventDuration);
}
// otherwise, set duration to zero this should never happen
else {
Expand Down Expand Up @@ -220,7 +223,7 @@
foreach ($events as $vevent) {
$this->recurrenceModified[$vevent->{'RECURRENCE-ID'}->getDateTime($this->baseEventStartTimeZone)->getTimeStamp()] = $vevent;
}

$this->recurrenceCurrentDate = clone $this->baseEventStartDate;
}

Expand Down
Loading