Add `WC::defineLegacyOptions()` (#4137)
authorMatthias Schmidt <gravatronics@live.com>
Thu, 22 Apr 2021 08:08:29 +0000 (10:08 +0200)
committerGitHub <noreply@github.com>
Thu, 22 Apr 2021 08:08:29 +0000 (10:08 +0200)
Moving these definitions into a dedicated method removes "clutter" from `loadOptions()`.

wcfsetup/install/files/lib/system/WCF.class.php

index ba5c2abd8d66d452e325c63423f917de65569c7c..14f3a0cfe4a1e02e920f236860f38098f387b937 100644 (file)
@@ -366,6 +366,46 @@ class WCF
      * Loads the options file, automatically created if not exists.
      */
     protected function loadOptions()
+    {
+        $this->defineLegacyOptions();
+
+        $filename = WCF_DIR . 'options.inc.php';
+
+        // create options file if doesn't exist
+        if (!\file_exists($filename) || \filemtime($filename) <= 1) {
+            OptionEditor::rebuild();
+        }
+        require($filename);
+
+        // check if option file is complete and writable
+        if (PACKAGE_ID) {
+            if (!\is_writable($filename)) {
+                FileUtil::makeWritable($filename);
+
+                if (!\is_writable($filename)) {
+                    throw new SystemException("The option file '" . $filename . "' is not writable.");
+                }
+            }
+
+            // check if a previous write operation was incomplete and force rebuilding
+            if (!\defined('WCF_OPTION_INC_PHP_SUCCESS')) {
+                OptionEditor::rebuild();
+
+                require($filename);
+            }
+
+            if (ENABLE_DEBUG_MODE) {
+                self::$dbObj->enableDebugMode();
+            }
+        }
+    }
+
+    /**
+     * Defines constants for obsolete options, which were removed.
+     *
+     * @since   5.4
+     */
+    protected function defineLegacyOptions(): void
     {
         // The attachment module is always enabled since 5.2.
         // https://github.com/WoltLab/WCF/issues/2531
@@ -426,36 +466,6 @@ class WCF
         // Cover photos are always enabled since 5.4.
         // https://github.com/WoltLab/WCF/issues/3902
         \define('MODULE_USER_COVER_PHOTO', 1);
-
-        $filename = WCF_DIR . 'options.inc.php';
-
-        // create options file if doesn't exist
-        if (!\file_exists($filename) || \filemtime($filename) <= 1) {
-            OptionEditor::rebuild();
-        }
-        require($filename);
-
-        // check if option file is complete and writable
-        if (PACKAGE_ID) {
-            if (!\is_writable($filename)) {
-                FileUtil::makeWritable($filename);
-
-                if (!\is_writable($filename)) {
-                    throw new SystemException("The option file '" . $filename . "' is not writable.");
-                }
-            }
-
-            // check if a previous write operation was incomplete and force rebuilding
-            if (!\defined('WCF_OPTION_INC_PHP_SUCCESS')) {
-                OptionEditor::rebuild();
-
-                require($filename);
-            }
-
-            if (ENABLE_DEBUG_MODE) {
-                self::$dbObj->enableDebugMode();
-            }
-        }
     }
 
     /**