From 8edbbca7353268b5b6ab0ecd6fe75dfe1f85ce6d Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Fri, 26 May 2023 16:19:38 +0200 Subject: [PATCH 1/2] Fix double insertion of answers --- docs/CHANGELOG.md | 7 ++++--- models/Poll.php | 4 +++- module.json | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3ff8863..58ff711 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +1.3.1 (Unreleased) +------------------- +- Fix #123: Fix double insertion of answers + 1.3.0 (May 1, 2023) ------------------- - Fix #122: Hard delete records on disable module @@ -111,6 +115,3 @@ Changelog 0.9.11 - 12 April, 2018 ------------------------ - Enh: Added `Hide results until poll is closed?` option. - - - diff --git a/models/Poll.php b/models/Poll.php index 2ad2321..30a8ab6 100644 --- a/models/Poll.php +++ b/models/Poll.php @@ -193,7 +193,9 @@ public function saveNewAnswers() foreach ($this->newAnswers as $answerText) { $this->addAnswer($answerText); } - + // Reset already inserted answers to avoid their duplicates + $this->newAnswers = null; + // Reset cached answers unset($this->answers); } diff --git a/module.json b/module.json index 83e8f1c..8473f9a 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "Polls", "description": "Easy to use poll system", "keywords": ["poll", "voting", "decision making"], - "version": "1.3.0", + "version": "1.3.1", "humhub": { "minVersion": "1.14" }, From 09c24e9b9c40d6c20067a025fcb7c2193e0a7d8e Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Fri, 26 May 2023 19:05:51 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- docs/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 58ff711..36619d3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,8 +1,8 @@ Changelog ========= -1.3.1 (Unreleased) -------------------- +1.3.1 (May 26, 2023) +-------------------- - Fix #123: Fix double insertion of answers 1.3.0 (May 1, 2023)