Skip to content
Snippets Groups Projects
Commit f75b01f1 authored by dpi's avatar dpi
Browse files

Issue #3323047 by dpi: Review sidebar infinite loop

parent 40e3ec92
Branches
Tags 3.1.0-beta2
1 merge request!6Issue #3323047: Review sidebar infinite loop
......@@ -85,7 +85,7 @@ function template_preprocess_oh_review_occurrences_list(array &$variables): void
ksort($days);
$startOfWeek = (new \DateTime())
->setISODate(...explode('-', $weekCode))
->setISODate(...array_map('intval', explode('-', $weekCode)))
->setTime(0, 0, 0, 0);
$week = [
'days' => [],
......@@ -110,10 +110,10 @@ function template_preprocess_oh_review_occurrences_list(array &$variables): void
foreach ($occurrences as $occurrence) {
$dayInfo['times'][] = [
'attributes' => (new Attribute())->addClass($occurrence->isOpen() ? 'is-open' : 'is-closed'),
'start' => $occurrence->getStart()->format($timeFormat),
'end' => $occurrence->getEnd()->format($timeFormat),
'start' => $occurrence->period()->getStartDate()->format($timeFormat),
'end' => $occurrence->period()->getEndDate()->format($timeFormat),
'is_open' => $occurrence->isOpen(),
'is_full_day' => $isFullDay($occurrence->getStart(), $occurrence->getEnd()),
'is_full_day' => $isFullDay($occurrence->period()->getStartDate(), $occurrence->period()->getEndDate()),
'message' => implode(',', $occurrence->getMessages()),
];
$open = ($open or $occurrence->isOpen());
......
......@@ -29,25 +29,26 @@ final class OhReviewUtility {
$weekFormat = 'o-W';
$dayFormat = 'Y-m-d';
/** @var array<string, \Drupal\oh\OhOccurrence[]> $occurrencesByDay */
$occurrencesByDay = [];
if ($fillDays) {
// Fill in the days.
$fillPointer = $range->getStart();
$fillEnd = $range->getEnd();
$fillEnd->modify('-1 second');
$fillPointer = $range->period()->getStartDate();
$fillEnd = $range->period()->getEndDate();
$fillEnd = $fillEnd->modify('-1 second');
while ($fillPointer < $fillEnd) {
$pointerDay = $fillPointer->format($dayFormat);
if (!isset($occurrencesByDay[$pointerDay])) {
$occurrencesByDay[$pointerDay] = [];
}
$fillPointer->modify('+1 day');
$fillPointer = $fillPointer->modify('+1 day');
}
}
uasort($occurrences, [OhOccurrence::class, 'sort']);
foreach ($occurrences as $occurrence) {
$day = $occurrence->getStart()->format($dayFormat);
$day = $occurrence->period()->getStartDate()->format($dayFormat);
$occurrencesByDay[$day][] = $occurrence;
}
......@@ -61,8 +62,8 @@ final class OhReviewUtility {
$groupedByWeek[$week][$dayCode] = $groupedByWeek[$week][$dayCode] ?? [];
}
foreach ($occurrences as $occurrence) {
$week = $occurrence->getStart()->format($weekFormat);
$day = $occurrence->getStart()->format($dayFormat);
$week = $occurrence->period()->getStartDate()->format($weekFormat);
$day = $occurrence->period()->getStartDate()->format($dayFormat);
$groupedByWeek[$week][$day][] = $occurrence;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment