From 77f05b1c2112db68bba8a8b30a945ad9cfe83946 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Feb 2018 19:29:56 +0100 Subject: [PATCH] fix issue with check for maxValue Signed-off-by: Thomas Citharel --- app/classes/Framadate/Services/PollService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index c967d0a..1adc6f8 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -146,7 +146,7 @@ class PollService { /** * @param Form $form - * @return string + * @return array */ function createPoll(Form $form) { // Generate poll IDs, loop while poll ID already exists @@ -289,7 +289,11 @@ class PollService { * @throws ConcurrentVoteException */ private function checkMaxVotes($user_choice, $poll, $poll_id) { - $best_choices = $this->computeBestChoices($this->allVotesByPollId($poll_id)); + $votes = $this->allVotesByPollId($poll_id); + if (count($votes) <= 0) { + return; + } + $best_choices = $this->computeBestChoices($votes); foreach ($best_choices['y'] as $i => $nb_choice) { // if for this option we have reached maximum value and user wants to add itself too if ($nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") {