Skip to content

Commit afe0029

Browse files
committed
Return a clone of the occurrence, so we don't modify the same instance multiple times
1 parent 8f6e002 commit afe0029

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/Tags/Events.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,16 @@ private function day(string $date, EntryCollection $occurrences): array
141141
return [
142142
'date' => $date,
143143
'occurrences' => $occurrences->map(function (Entry $occurrence) use ($date): Entry {
144-
if ($occurrence->spanning) {
145-
$carbonDate = Carbon::parse($date)->shiftTimezone($occurrence->start->timezone);
146-
$occurrence
147-
->setSupplement('spanning_start', $occurrence->start->isSameDay($carbonDate))
148-
->setSupplement('spanning_end', $occurrence->end->isSameDay($carbonDate));
144+
if (!$occurrence->spanning) {
145+
return $occurrence;
149146
}
150147

151-
return $occurrence;
148+
$carbonDate = Carbon::parse($date)->shiftTimezone($occurrence->start->timezone);
149+
$occurrence
150+
->setSupplement('spanning_start', $occurrence->start->isSameDay($carbonDate))
151+
->setSupplement('spanning_end', $occurrence->end->isSameDay($carbonDate));
152+
153+
return clone $occurrence;
152154
})->values(),
153155
];
154156
}

0 commit comments

Comments
 (0)