Fix tag search if no tag is entered
authorMatthias Schmidt <gravatronics@live.com>
Sat, 5 Jan 2019 09:32:08 +0000 (10:32 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 5 Jan 2019 09:32:08 +0000 (10:32 +0100)
See #2689

com.woltlab.wcf/templates/tagSearch.tpl
wcfsetup/install/files/lib/form/TagSearchForm.class.php

index b824483ca2c3239988437b3a2166bf68ad0ad006..39833b9438e0ffedd65b948af598622a0ea86f93 100644 (file)
                                        <dt><label for="tagSearchInput">{lang}wcf.tagging.tags{/lang}</label></dt>
                                        <dd>
                                                <input id="tagSearchInput" type="text" value="" class="long">
+                                               {if $errorField === 'tags'}
+                                                       <small class="innerError">
+                                                               {if $errorType == 'empty'}
+                                                                       {lang}wcf.global.form.error.empty{/lang}
+                                                               {else}
+                                                                       {lang}wcf.tagging.tags.error.{$errorType}{/lang}
+                                                               {/if}
+                                                       </small>
+                                               {/if}
                                                <small>{lang}wcf.tagging.tags.description{/lang}</small>
                                        </dd>
                                </dl>
index 8595798e03eac4a1dacd903efb0f7e11a2390f01..acc7d6b18b5bc1e3d483b7c136da6b233b961daf 100644 (file)
@@ -82,8 +82,13 @@ class TagSearchForm extends AbstractCaptchaForm {
                        }
                }
                
-               $this->tags = TagEngine::getInstance()->getTagsByName($this->tagNames, $this->languageID);
-               if (empty($this->tags)) {
+               if (!empty($this->tagNames)) {
+                       $this->tags = TagEngine::getInstance()->getTagsByName($this->tagNames, $this->languageID);
+                       if (empty($this->tags)) {
+                               throw new UserInputException('tags');
+                       }
+               }
+               else {
                        throw new UserInputException('tags');
                }
        }