From 7ffd7f0b21cad701973f64b6541b8408e4fbd53e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 19 Mar 2018 10:23:35 +0100 Subject: [PATCH 1/3] Fix unable to vote with ConcurrentVoteException when ValueMax is null Closes #276 Signed-off-by: Thomas Citharel --- app/classes/Framadate/Services/PollService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index 1adc6f8..165a924 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -296,7 +296,7 @@ class PollService { $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") { + if ($poll->ValueMax != null && $nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") { throw new ConcurrentVoteException(); } } From eadf775bb32523225ea044c3bcb7403ab565c87e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 19 Mar 2018 10:24:31 +0100 Subject: [PATCH 2/3] Fix generating URL issue with type check Signed-off-by: Thomas Citharel --- app/classes/Framadate/Utils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php index 8249c44..26d64bb 100644 --- a/app/classes/Framadate/Utils.php +++ b/app/classes/Framadate/Utils.php @@ -88,7 +88,7 @@ class Utils { */ public static function getUrlSondage($id, $admin = false, $vote_id = '', $action = null, $action_value = null) { // URL-Encode $action_value - $action_value = $action_value === null ? null : Utils::base64url_encode($action_value); + $action_value = $action_value ? null : Utils::base64url_encode($action_value); if (URL_PROPRE) { if ($admin === true) { @@ -98,8 +98,8 @@ class Utils { } if ($vote_id !== '') { $url .= '/vote/' . $vote_id . "#edit"; - } elseif ($action !== null) { - if ($action_value !== null) { + } elseif ($action) { + if ($action_value) { $url .= '/action/' . $action . '/' . $action_value; } else { $url .= '/action/' . $action; From 26761c97a6b0e24e98b80f47c9f8572348e4871b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 19 Mar 2018 10:26:00 +0100 Subject: [PATCH 3/3] CS Signed-off-by: Thomas Citharel --- app/classes/Framadate/Services/PollService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index 165a924..104c6f6 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -296,7 +296,7 @@ class PollService { $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 ($poll->ValueMax != null && $nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") { + if ($poll->ValueMax !== null && $nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") { throw new ConcurrentVoteException(); } }