From 1a4deb986554007440972f79b393f0f02e2e621b Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 11 Jun 2021 16:33:08 +0200 Subject: [PATCH] Move developer mode setup into separate method --- .../PackageInstallationDispatcher.class.php | 118 ++++++++++-------- 1 file changed, 66 insertions(+), 52 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index ee98ad09be..894519bca4 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -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. * -- 2.20.1