A free, self-hostable news aggregator…
fix: add default values on stat processing (#7891)
Alexis Degrugillierd31f485973f7
diff --git a/app/views/stats/index.phtml b/app/views/stats/index.phtmlindex 88c4f0a3c..542ac487c 100644--- a/app/views/stats/index.phtml+++ b/app/views/stats/index.phtml@@ -112,7 +112,7 @@ function generateColorPalette(int $count): array {}// 1. Get all unique category labels and sort them-$allLabels = array_unique(array_merge($this->feedByCategory['label'], $this->entryByCategory['label']));+$allLabels = array_unique(array_merge($this->feedByCategory['label'] ?? [], $this->entryByCategory['label'] ?? []));sort($allLabels); // Ensure consistent order// 2. Generate a color palette based on the number of unique categories@@ -123,11 +123,11 @@ $colorMap = array_combine($allLabels, $colorPalette);// 4. Align data and labels for both charts$feedData = array_fill_keys($allLabels, 0); // Initialize data with all categories-foreach ($this->feedByCategory['label'] as $index => $label) {+foreach ($this->feedByCategory['label'] ?? [] as $index => $label) {$feedData[$label] = $this->feedByCategory['data'][$index];}$entryData = array_fill_keys($allLabels, 0); // Initialize data with all categories-foreach ($this->entryByCategory['label'] as $index => $label) {+foreach ($this->entryByCategory['label'] ?? [] as $index => $label) {$entryData[$label] = $this->entryByCategory['data'][$index];}