Skip to content
Draft
Show file tree
Hide file tree
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
25 changes: 22 additions & 3 deletions apps/dav/lib/CalDAV/Reminder/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public function getRemindersToProcess():array {
->from('calendar_reminders', 'cr')
->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
->join('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
->join('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'))
->groupBy('cr.event_hash', 'cr.notification_date', 'cr.type', 'cr.id', 'cr.calendar_id', 'cr.object_id', 'cr.is_recurring', 'cr.uid', 'cr.recurrence_id', 'cr.is_recurrence_exception', 'cr.alarm_hash', 'cr.is_relative', 'cr.is_repeat_based', 'co.calendardata', 'c.displayname', 'c.principaluri');
->join('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'));
$stmt = $query->executeQuery();

return array_map(
[$this, 'fixRowTyping'],
$stmt->fetchAllAssociative()
$this->deduplicateReminderRows($stmt->fetchAllAssociative())
);
}

Expand Down Expand Up @@ -178,6 +177,26 @@ public function cleanRemindersForCalendar(int $calendarId):void {
->executeStatement();
}

/**
* @param array<array<string, mixed>> $rows
* @return array<array<string, mixed>>
*/
private function deduplicateReminderRows(array $rows): array {
$uniqueRows = [];
foreach ($rows as $row) {
$key = implode("\0", [
(string)$row['notification_date'],
(string)$row['event_hash'],
(string)$row['type'],
]);
if (!isset($uniqueRows[$key])) {
$uniqueRows[$key] = $row;
}
}

return array_values($uniqueRows);
}

/**
* @param array $row
* @return array
Expand Down
Loading
Loading