From: Marcel Werk Date: Wed, 9 Nov 2016 11:48:18 +0000 (+0100) Subject: Resolved todos in update script X-Git-Tag: 3.0.0_Beta_5~65 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=21656f2621871ddd0e06fce1fbfc1b9b51445989;p=GitHub%2FWoltLab%2FWCF.git Resolved todos in update script --- diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_post_sql.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_post_sql.php index c5564604fb..4d3dd5c3cd 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_post_sql.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_post_sql.php @@ -1,20 +1,95 @@ readObjects(); +foreach ($groupList as $group) { + $showOrder = 1; + $labelList = new LabelList(); + $labelList->getConditionBuilder()->add('groupID = ?', [$group->groupID]); + $labelList->sqlOrderBy = 'label'; + $labelList->readObjects(); + foreach ($labelList as $label) { + $editor = new LabelEditor($label); + $editor->update(['showOrder' => $showOrder]); + $showOrder++; + } +} +// If a template group uses '_wcf_email' as the folder: Move it! +$templateGroupList = new TemplateGroupList(); +$templateGroupList->getConditionBuilder()->add('templateGroupFolderName = ? AND templateGroupName <> ?', ['_wcf_email/', 'wcf.acp.template.group.email']); +$templateGroupList->readObjects(); +foreach ($templateGroupList as $templateGroup) { + $i = 1; + do { + $newTemplateGroupFolderName = FileUtil::addTrailingSlash(FileUtil::removeTrailingSlash($templateGroup->templateGroupFolderName) . $i); + $i++; + } + while (file_exists(WCF_DIR . 'templates/' . $newTemplateGroupFolderName)); + + @rename(WCF_DIR . 'templates/' . $templateGroup->templateGroupFolderName, WCF_DIR . 'templates/' . $newTemplateGroupFolderName); + $editor = new TemplateGroupEditor($templateGroup); + $editor->update(['templateGroupFolderName' => $newTemplateGroupFolderName]); +} -// add vortex update servers if missing +// Fill in the mail_* constants with something sane. +$sql = "UPDATE wcf".WCF_N."_option + SET optionValue = ? + WHERE optionName = ?"; +$statement = WCF::getDB()->prepareStatement($sql); +$statement->execute([ + WCF::getUser()->username, + 'mail_from_name' +]); +$statement->execute([ + WCF::getUser()->email, + 'mail_from_address' +]); +$statement->execute([ + WCF::getUser()->email, + 'mail_admin_address' +]); +// Generate signature_secret +try { + $statement->execute([ + bin2hex(CryptoUtil::randomBytes(20)), + 'signature_secret' + ]); +} +catch (CryptoException $e) { + // ignore, the secret will stay empty and crypto operations + // depending on it will fail +} +// add vortex update servers if missing +$serverURLs = [ + 'http://update.woltlab.com/vortex/', + 'http://store.woltlab.com/vortex/' +]; +foreach ($serverURLs as $serverURL) { + $sql = "SELECT COUNT(*) AS count + FROM wcf" . WCF_N . "_package_update_server + WHERE serverURL = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute([$serverURL]); + if (!$statement->fetchColumn()) { + $sql = "INSERT INTO wcf" . WCF_N . "_package_update_server + (serverURL) + VALUES (?)"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute([$serverURL]); + } +} // set default landing page $sql = "UPDATE wcf".WCF_N."_page