From a120debac6c7aca8286a570f9fbd5328e30f3cd0 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 7 Dec 2023 09:59:39 +0000 Subject: [PATCH] Fix for exception when there are "null" replies --- src/Model/Item.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 0e741ce816..5458514aa5 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3805,16 +3805,16 @@ class Item foreach ($options as $key => $option) { if ($question['voters'] > 0) { $percent = $option['replies'] / $question['voters'] * 100; - $options[$key]['vote'] = DI::l10n()->tt('%2$s (%3$d%%, %1$d vote)', '%2$s (%3$d%%, %1$d votes)', $option['replies'], $option['name'], round($percent, 1)); + $options[$key]['vote'] = DI::l10n()->tt('%2$s (%3$d%%, %1$d vote)', '%2$s (%3$d%%, %1$d votes)', $option['replies'] ?? 0, $option['name'], round($percent, 1)); } else { - $options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'], $option['name']); + $options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'] ?? 0, $option['name']); } } if (!empty($question['voters']) && !empty($question['endtime'])) { - $summary = DI::l10n()->tt('%d voter. Poll end: %s', '%d voters. Poll end: %s', $question['voters'], Temporal::getRelativeDate($question['endtime'])); + $summary = DI::l10n()->tt('%d voter. Poll end: %s', '%d voters. Poll end: %s', $question['voters'] ?? 0, Temporal::getRelativeDate($question['endtime'])); } elseif (!empty($question['voters'])) { - $summary = DI::l10n()->tt('%d voter.', '%d voters.', $question['voters']); + $summary = DI::l10n()->tt('%d voter.', '%d voters.', $question['voters'] ?? 0); } elseif (!empty($question['endtime'])) { $summary = DI::l10n()->t('Poll end: %s', Temporal::getRelativeDate($question['endtime'])); } else { -- 2.39.5