Return a sane list of defaults if the selected highlighters are empty
authorAlexander Ebert <ebert@woltlab.com>
Thu, 14 Nov 2024 11:21:02 +0000 (12:21 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 14 Nov 2024 11:21:02 +0000 (12:21 +0100)
In previous versions it was possible that the selection got lost, eventually breaking the implementation.

wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php

index 60814a938b9bb047f7f513ba4a5a5b0f491c0807..ea228ee98dda85d453d928c6fdb051c035395054 100644 (file)
@@ -189,7 +189,30 @@ class BBCodeHandler extends SingletonFactory
      */
     public function getCodeBlockLanguages(): array
     {
-        return \explode("\n", StringUtil::unifyNewlines(\MESSAGE_PUBLIC_HIGHLIGHTERS));
+        $highlighters = \explode("\n", StringUtil::unifyNewlines(\MESSAGE_PUBLIC_HIGHLIGHTERS));
+        if ($highlighters !== []) {
+            return $highlighters;
+        }
+
+        return [
+            'c',
+            'cpp',
+            'csharp',
+            'css',
+            'go',
+            'html',
+            'java',
+            'javascript',
+            'json',
+            'php',
+            'python',
+            'ruby',
+            'rust',
+            'sql',
+            'typescript',
+            'xml',
+            'yaml',
+        ];
     }
 
     /**