Move developer mode setup into separate method
authorMatthias Schmidt <gravatronics@live.com>
Fri, 11 Jun 2021 14:33:08 +0000 (16:33 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 11 Jun 2021 14:44:48 +0000 (16:44 +0200)
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index ee98ad09be42fdd1ef27de02a9ab36700c4efc10..894519bca46d39d55f9fbc327478a98d546d0671 100644 (file)
@@ -261,58 +261,7 @@ class PackageInstallationDispatcher
                     );
 
                     if (WCF::getSession()->getVar('__wcfSetup_developerMode')) {
-                        $statement->execute([
-                            1,
-                            'enable_debug_mode',
-                        ]);
-                        $statement->execute([
-                            'public',
-                            'exception_privacy',
-                        ]);
-                        $statement->execute([
-                            'debugFolder',
-                            'mail_send_method',
-                        ]);
-                        $statement->execute([
-                            1,
-                            'enable_developer_tools',
-                        ]);
-                        $statement->execute([
-                            1,
-                            'log_missing_language_items',
-                        ]);
-
-                        foreach (DevtoolsSetup::getInstance()->getOptionOverrides() as $optionName => $optionValue) {
-                            $statement->execute([
-                                $optionValue,
-                                $optionName,
-                            ]);
-                        }
-
-                        foreach (DevtoolsSetup::getInstance()->getUsers() as $newUser) {
-                            try {
-                                (new UserAction([], 'create', [
-                                    'data' => [
-                                        'email' => $newUser['email'],
-                                        'password' => $newUser['password'],
-                                        'username' => $newUser['username'],
-                                    ],
-                                    'groups' => [
-                                        1,
-                                        3,
-                                    ],
-                                ]))->executeAction();
-                            } catch (SystemException $e) {
-                                // ignore errors due to event listeners missing at this
-                                // point during installation
-                            }
-                        }
-
-                        if (($importPath = DevtoolsSetup::getInstance()->getDevtoolsImportPath()) !== '') {
-                            (new DevtoolsProjectAction([], 'quickSetup', [
-                                'path' => $importPath,
-                            ]))->executeAction();
-                        }
+                        $this->setupDeveloperMode();
                     }
 
                     if (WCF::getSession()->getVar('__wcfSetup_imagick')) {
@@ -385,6 +334,71 @@ class PackageInstallationDispatcher
         return $step;
     }
 
+    /**
+     * @since   5.5
+     */
+    protected function setupDeveloperMode(): void
+    {
+        $sql = "UPDATE  wcf" . WCF_N . "_option
+                SET     optionValue = ?
+                WHERE   optionName = ?";
+        $statement = WCF::getDB()->prepareStatement($sql);
+
+        $statement->execute([
+            1,
+            'enable_debug_mode',
+        ]);
+        $statement->execute([
+            'public',
+            'exception_privacy',
+        ]);
+        $statement->execute([
+            'debugFolder',
+            'mail_send_method',
+        ]);
+        $statement->execute([
+            1,
+            'enable_developer_tools',
+        ]);
+        $statement->execute([
+            1,
+            'log_missing_language_items',
+        ]);
+
+        foreach (DevtoolsSetup::getInstance()->getOptionOverrides() as $optionName => $optionValue) {
+            $statement->execute([
+                $optionValue,
+                $optionName,
+            ]);
+        }
+
+        foreach (DevtoolsSetup::getInstance()->getUsers() as $newUser) {
+            try {
+                (new UserAction([], 'create', [
+                    'data' => [
+                        'email' => $newUser['email'],
+                        'password' => $newUser['password'],
+                        'username' => $newUser['username'],
+                    ],
+                    'groups' => [
+                        1,
+                        3,
+                    ],
+                ]))->executeAction();
+            } catch (SystemException $e) {
+                // ignore errors due to event listeners missing at this
+                // point during installation
+            }
+        }
+
+        $importPath = DevtoolsSetup::getInstance()->getDevtoolsImportPath();
+        if ($importPath !== '') {
+            (new DevtoolsProjectAction([], 'quickSetup', [
+                'path' => $importPath,
+            ]))->executeAction();
+        }
+    }
+
     /**
      * Logs an installation step.
      *