Stop checking the `enable_censorship` option
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 22 Oct 2021 09:28:16 +0000 (11:28 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 22 Oct 2021 09:29:49 +0000 (11:29 +0200)
wcfsetup/install/files/lib/form/MessageForm.class.php
wcfsetup/install/files/lib/system/comment/CommentHandler.class.php
wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php
wcfsetup/install/files/lib/system/option/AboutMeOptionType.class.php

index d570c8c00dbb6773f27b1021b8ab388d430e01d9..45dc408beee1aee031e8cd9254049c40e30f4941 100644 (file)
@@ -202,13 +202,10 @@ abstract class MessageForm extends AbstractCaptchaForm
             $this->subject = \mb_substr($this->subject, 0, 255);
         }
 
-        // search for censored words
-        if (ENABLE_CENSORSHIP) {
-            $result = Censorship::getInstance()->test($this->subject);
-            if ($result) {
-                WCF::getTPL()->assign('censoredWords', $result);
-                throw new UserInputException('subject', 'censoredWordsFound');
-            }
+        $censoredWords = Censorship::getInstance()->test($this->subject);
+        if ($censoredWords) {
+            WCF::getTPL()->assign('censoredWords', $censoredWords);
+            throw new UserInputException('subject', 'censoredWordsFound');
         }
     }
 
@@ -251,12 +248,10 @@ abstract class MessageForm extends AbstractCaptchaForm
         }
 
         // search for censored words
-        if (ENABLE_CENSORSHIP) {
-            $result = Censorship::getInstance()->test($message);
-            if ($result) {
-                WCF::getTPL()->assign('censoredWords', $result);
-                throw new UserInputException('text', 'censoredWordsFound');
-            }
+        $censoredWords = Censorship::getInstance()->test($message);
+        if ($censoredWords) {
+            WCF::getTPL()->assign('censoredWords', $censoredWords);
+            throw new UserInputException('text', 'censoredWordsFound');
         }
     }
 
index 288c63280bc5f3a0a944678011300c0ab8ddf527..f4a7c3ecfbac2e48db2c3994c0c9c48c460b8f69 100644 (file)
@@ -735,18 +735,15 @@ class CommentHandler extends SingletonFactory
      */
     public static function enforceCensorship($text)
     {
-        // search for censored words
-        if (ENABLE_CENSORSHIP) {
-            $result = Censorship::getInstance()->test($text);
-            if ($result) {
-                throw new UserInputException(
-                    'text',
-                    WCF::getLanguage()->getDynamicVariable(
-                        'wcf.message.error.censoredWordsFound',
-                        ['censoredWords' => $result]
-                    )
-                );
-            }
+        $censoredWords = Censorship::getInstance()->test($text);
+        if ($censoredWords) {
+            throw new UserInputException(
+                'text',
+                WCF::getLanguage()->getDynamicVariable(
+                    'wcf.message.error.censoredWordsFound',
+                    ['censoredWords' => $censoredWords]
+                )
+            );
         }
     }
 }
index 5b3fc4ff5a891e4f406588b757f34a14238374b0..43ef8b85d1604176d4f73518f577c2c6931ffb28 100644 (file)
@@ -435,13 +435,13 @@ class WysiwygFormField extends AbstractFormField implements
                     $this->validateMinimumLength($message);
                     $this->validateMaximumLength($message);
 
-                    if (empty($this->getValidationErrors()) && ENABLE_CENSORSHIP) {
-                        $result = Censorship::getInstance()->test($message);
-                        if ($result) {
+                    if (empty($this->getValidationErrors())) {
+                        $censoredWords = Censorship::getInstance()->test($message);
+                        if ($censoredWords) {
                             $this->addValidationError(new FormFieldValidationError(
                                 'censoredWords',
                                 'wcf.message.error.censoredWordsFound',
-                                ['censoredWords' => $result]
+                                ['censoredWords' => $censoredWords]
                             ));
                         }
                     }
index 6f999c91b7d7961ebbdc3397bee7ae622bf2b47b..35dc117167954449e6b56123618f1c6b69339b30 100644 (file)
@@ -28,13 +28,10 @@ class AboutMeOptionType extends MessageOptionType
             throw new UserInputException($option->optionName, 'tooLong');
         }
 
-        // search for censored words
-        if (ENABLE_CENSORSHIP) {
-            $result = Censorship::getInstance()->test($newValue);
-            if ($result) {
-                WCF::getTPL()->assign('censoredWords', $result);
-                throw new UserInputException($option->optionName, 'censoredWordsFound');
-            }
+        $censoredWords = Censorship::getInstance()->test($newValue);
+        if ($censoredWords) {
+            WCF::getTPL()->assign('censoredWords', $censoredWords);
+            throw new UserInputException($option->optionName, 'censoredWordsFound');
         }
     }
 }