From: Tim Schiewe Date: Tue, 7 Jun 2016 12:27:44 +0000 (+0200) Subject: Fixed check for empty polls X-Git-Tag: 3.0.0_Beta_1~117^2~58^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5fe0a2915338c3c5346bc5722ba385c3e9477daf;p=GitHub%2FWoltLab%2FWCF.git Fixed check for empty polls If the question was empty, the poll was discarded, even when the user gave options. This could lead to frustation as all options had to be typed again. --- diff --git a/com.woltlab.wcf/templates/__messageFormPoll.tpl b/com.woltlab.wcf/templates/__messageFormPoll.tpl index 78a905e729..9a2f7f90a9 100644 --- a/com.woltlab.wcf/templates/__messageFormPoll.tpl +++ b/com.woltlab.wcf/templates/__messageFormPoll.tpl @@ -14,13 +14,20 @@
- +
+ {if $errorField == 'pollQuestion'} + + {lang}wcf.global.form.error.empty{/lang} + + {/if}
+ +
diff --git a/wcfsetup/install/files/lib/system/poll/PollManager.class.php b/wcfsetup/install/files/lib/system/poll/PollManager.class.php index dd7898374c..10b54d67f2 100644 --- a/wcfsetup/install/files/lib/system/poll/PollManager.class.php +++ b/wcfsetup/install/files/lib/system/poll/PollManager.class.php @@ -197,10 +197,17 @@ class PollManager extends SingletonFactory { * Validates poll parameters. */ public function validate() { - // if no question is given, ignore poll completely - if (empty($this->pollData['question'])) { + $count = count($this->pollOptions); + + // if no question and no options are given, ignore poll completely + if (empty($this->pollData['question']) && !$count) { return; } + + // no question given + if (empty($this->pollData['question'])) { + throw new UserInputException('pollQuestion'); + } if ($this->pollData['endTime'] && $this->pollData['endTime'] <= TIME_NOW) { if ($this->poll === null || $this->poll->endTime >= TIME_NOW) { @@ -210,7 +217,6 @@ class PollManager extends SingletonFactory { } // no options given - $count = count($this->pollOptions); if (!$count) { throw new UserInputException('pollOptions'); }