Skip to content

Commit

Permalink
[BUGFIX] Fix undefined array key "single" in NewsRepository (#2181)
Browse files Browse the repository at this point in the history
Fixes: #2171
  • Loading branch information
nhovratov authored Aug 28, 2023
1 parent 87b4bee commit 4376c5d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Classes/Domain/Repository/NewsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,12 @@ public function countByDate(DemandInterface $demand): array
}
}
// Add totals
if (is_array($data['single'])) {
foreach ($data['single'] as $year => $months) {
$countOfYear = 0;
foreach ($months as $month) {
$countOfYear += $month;
}
$data['total'][$year] = $countOfYear;
foreach ($data['single'] ?? [] as $year => $months) {
$countOfYear = 0;
foreach ($months as $month) {
$countOfYear += $month;
}
$data['total'][$year] = $countOfYear;
}

return $data;
Expand Down

0 comments on commit 4376c5d

Please sign in to comment.