diff --git a/lib/base/dao/dao.class.php b/lib/base/dao/dao.class.php index 2491327fb3..bfa485ab0d 100644 --- a/lib/base/dao/dao.class.php +++ b/lib/base/dao/dao.class.php @@ -292,6 +292,18 @@ class baseDAO $this->dbh->beginTransaction(); } + /** + * 检查是否在事务内。 + * Check in transaction. + * + * @access public + * @return bool + */ + public function inTransaction() + { + $this->dbh->inTransaction(); + } + /** * 事务回滚。 * Roll back diff --git a/module/upgrade/config.php b/module/upgrade/config.php index 3200fe6e2c..5aeeba993c 100644 --- a/module/upgrade/config.php +++ b/module/upgrade/config.php @@ -976,3 +976,5 @@ $config->upgrade->recoveryActions->testcase->review['open'] = 'normal'; $config->upgrade->recoveryActions->testcase->review['position'] = 'browseandview'; $config->upgrade->missedFlowFieldVersions = array('max4_4_alpha1', 'max4_4_beta1', 'max4_4', 'max4_5', 'biz8_4_alpha1', 'biz8_4_beta1', 'biz8_4', 'biz8_5'); + +include dirname(__FILE__) . DS . 'config' . DS . 'upgradeflow.php'; diff --git a/module/upgrade/config/upgradeflow.php b/module/upgrade/config/upgradeflow.php new file mode 100644 index 0000000000..b2d960dd1d --- /dev/null +++ b/module/upgrade/config/upgradeflow.php @@ -0,0 +1,160 @@ +getAppRoot()); + +$config->upgrade->execFlow = array(); +$config->upgrade->execFlow['1_0beta'] = array('functions' => 'updateCompany'); +$config->upgrade->execFlow['1_2'] = array('functions' => 'updateUBB,updateNL1_2'); +$config->upgrade->execFlow['1_3'] = array('functions' => 'updateNL1_3,updateTasks'); +$config->upgrade->execFlow['2_2'] = array('functions' => 'updateCases,updateActivatedCountOfBug'); +$config->upgrade->execFlow['3_0_beta1'] = array('functions' => 'updateAction,setOrderData'); +$config->upgrade->execFlow['3_3'] = array('functions' => 'updateTaskAssignedTo'); +$config->upgrade->execFlow['4_0_beta2'] = array('functions' => 'updateProjectType,updateEstimatePriv'); +$config->upgrade->execFlow['4_0_1'] = array('functions' => 'addPriv4_0_1'); +$config->upgrade->execFlow['4_1'] = array('functions' => 'addPriv4_1,processTaskFinish,deleteCompany'); +$config->upgrade->execFlow['5_2_1'] = array('functions' => 'mergeProjectGoalAndDesc'); +$config->upgrade->execFlow['6_0_beta1'] = array('functions' => 'toLowerTable,fixBugOSInfo,fixTaskFinishedBy'); +$config->upgrade->execFlow['6_0'] = array('functions' => 'fixDataIndex'); +$config->upgrade->execFlow['7_1'] = array('functions' => 'initOrder'); +$config->upgrade->execFlow['7_3'] = array('functions' => 'adjustPriv7_4_beta'); +$config->upgrade->execFlow['8_0_1'] = array('functions' => 'addPriv8_1'); +$config->upgrade->execFlow['8_1_3'] = array('functions' => 'addPriv8_2_beta,adjustConfigSectionAndKey'); +$config->upgrade->execFlow['8_2_6'] = array('functions' => 'adjustDocModule,moveDocContent,adjustPriv8_3'); +$config->upgrade->execFlow['8_3_1'] = array('functions' => 'renameMainLib,adjustPriv8_4'); +$config->upgrade->execFlow['9_0_beta'] = array('functions' => 'adjustPriv9_0'); +$config->upgrade->execFlow['9_0'] = array('functions' => 'fixProjectProductData'); +$config->upgrade->execFlow['9_0_1'] = array('functions' => 'addBugDeadlineToCustomFields,adjustPriv9_0_1'); +$config->upgrade->execFlow['9_1_2'] = array('functions' => 'processCustomMenus,adjustPriv9_2'); +$config->upgrade->execFlow['9_4'] = array('functions' => 'adjustPriv9_4'); +$config->upgrade->execFlow['9_5_1'] = array('functions' => 'initProjectStoryOrder'); +$config->upgrade->execFlow['9_6'] = array('functions' => 'fixDatatableColsConfig'); +$config->upgrade->execFlow['9_6_1'] = array('functions' => 'addLimitedGroup'); +$config->upgrade->execFlow['9_6_3'] = array('functions' => 'changeLimitedName,adjustPriv9_7,changeStoryWidth'); +$config->upgrade->execFlow['9_7'] = array('functions' => 'changeTeamFields,moveData2Notify'); +$config->upgrade->execFlow['9_8'] = array('functions' => 'fixTaskFinishedInfo'); +$config->upgrade->execFlow['9_8_1'] = array('functions' => 'fixTaskAssignedTo,fixProjectClosedInfo,resetProductLine'); +$config->upgrade->execFlow['9_8_2'] = array('functions' => 'addUniqueKeyToTeam'); +$config->upgrade->execFlow['9_8_3'] = array('functions' => 'adjustPriv10_0_alpha'); +$config->upgrade->execFlow['10_0_alpha'] = array('functions' => 'fixProjectStatisticBlock'); +$config->upgrade->execFlow['10_0'] = array('functions' => 'fixStorySpecTitle,removeUnlinkPriv'); +$config->upgrade->execFlow['10_1'] = array('xxsqls' => "$appRoot/db/xuanxuan.sql"); +$config->upgrade->execFlow['10_3_1'] = array('functions' => 'removeCustomMenu'); +$config->upgrade->execFlow['10_4'] = array('functions' => 'changeTaskParentValue'); +$config->upgrade->execFlow['10_4'] = array('functions' => 'initXuanxuan', 'xxsqls' => "$appRoot/db/upgradexuanxuan2.1.0.sql,$appRoot/db/upgradexuanxuan2.2.0.sql"); +$config->upgrade->execFlow['11_1'] = array('functions' => 'syncXXHttpsConfig', 'xxsqls' => "$appRoot/db/upgradexuanxuan2.3.0.sql"); +$config->upgrade->execFlow['11_2'] = array('functions' => 'processDocLibAcl'); +$config->upgrade->execFlow['11_3'] = array('functions' => 'addPriv11_4'); +$config->upgrade->execFlow['11_4_1'] = array('functions' => 'addPriv11_5,updateXX_11_5', 'xxsqls' => "$appRoot/db/upgradexuanxuan2.4.0.sql,$appRoot/db/upgradexuanxuan2.5.0.sql"); +$config->upgrade->execFlow['11_6_1'] = array('functions' => 'adjustWebhookType,adjustPriv11_6_2'); +$config->upgrade->execFlow['11_6_3'] = array('functions' => 'adjustPriv11_6_4'); +$config->upgrade->execFlow['11_6_5'] = array('functions' => 'fixGroupAcl,fixBugTypeList,adjustPriv11_7,rmEditorAndTranslateDir,setConceptSetted', 'xxsqls' => "$appRoot/db/upgradexuanxuan2.5.7.sql,$appRoot/db/upgradexuanxuan3.0.0-beta.1.sql,$appRoot/db/upgradexuanxuan3.0-beta3.sql"); +$config->upgrade->execFlow['11_7'] = array('functions' => 'adjustPriv12_0'); +$config->upgrade->execFlow['12_0_1'] = array('functions' => 'importRepoFromConfig'); +$config->upgrade->execFlow['12_1'] = array('xxsqls' => "$appRoot/db/upgradexuanxuan3.1.1.sql"); +$config->upgrade->execFlow['12_3_3'] = array('functions' => 'addPriv12_3_3,processImport2TaskBugs'); +$config->upgrade->execFlow['12_4_2'] = array('functions' => 'fixFromCaseVersion,initStoryOfPlan'); +$config->upgrade->execFlow['12_4_4'] = array('functions' => 'adjustPriv12_5'); +$config->upgrade->execFlow['12_5_3'] = array('functions' => 'adjustWhitelistOfProject,adjustWhitelistOfProduct,adjustPriv15_0'); +$config->upgrade->execFlow['15_0_rc1'] = array('functions' => 'adjustUserView'); +$config->upgrade->execFlow['15_0_rc3'] = array('functions' => 'updateLibType,updateRunCaseStatus,fix4TaskLinkProject,fixExecutionTeam', 'xxsqls' => "$appRoot/db/upgradexuanxuan3.3.sql,$appRoot/db/upgradexuanxuan4.0.sql,$appRoot/db/upgradexuanxuan4.0.beta2.sql,$appRoot/db/upgradexuanxuan4.0.beta3.sql"); +$config->upgrade->execFlow['15_0'] = array('functions' => 'adjustBugOfProject,processBuildTable,updateProductVersion'); +$config->upgrade->execFlow['15_0_2'] = array('functions' => 'uniqueProjectAdmin'); +$config->upgrade->execFlow['15_2'] = array('functions' => 'processGitlabRepo,processStoryFileType,processProductDoc,adjustPriv15_3'); +$config->upgrade->execFlow['15_3'] = array('functions' => 'adjustBugRequired,processTesttaskDate,processDocTempContent'); +$config->upgrade->execFlow['15_4'] = array('xxsqls' => "$appRoot/db/upgradexuanxuan4.2.sql,$appRoot/db/upgradexuanxuan4.4.sql"); +$config->upgrade->execFlow['15_5'] = array('functions' => 'addDefaultKanbanPri'); +$config->upgrade->execFlow['15_7_1'] = array('functions' => 'updateObjectBranch,updateProjectStories,updateProjectLinkedBranch'); +$config->upgrade->execFlow['16_0_beta1'] = array('functions' => 'createDemoAPI'); +$config->upgrade->execFlow['16_1'] = array('functions' => 'moveKanbanData'); +$config->upgrade->execFlow['16_2'] = array('functions' => 'updateSpaceTeam,updateDocField'); +$config->upgrade->execFlow['16_4'] = array('functions' => 'updateActivatedDate,completionAllSQL,updateGroup4Lite', 'xxsqls' => "$appRoot/db/upgradexuanxuan4.6.sql,$appRoot/db/upgradexuanxuan5.1.sql"); +$config->upgrade->execFlow['16_5'] = array('functions' => 'updateProjectStatus,updateStoryReviewer'); +$config->upgrade->execFlow['17_0_beta1'] = array('xxsqls' => "$appRoot/db/upgradexuanxuan5.5.sql"); +$config->upgrade->execFlow['17_0_beta2'] = array('functions' => 'changeStoryNeedReview'); +$config->upgrade->execFlow['17_0'] = array('functions' => 'replaceSetLanePriv,updateProjectData'); +$config->upgrade->execFlow['17_1'] = array('functions' => 'moveProjectAdmins,addStoryViewPriv', 'xxsqls' => "$appRoot/db/upgradexuanxuan5.6.sql", 'xxfunctions' => 'xuanAddMessageIndexColumns,xuanReindexMessages,xuanUpdateLastReadMessageIndex,xuanFixChatsWithoutLastRead'); +$config->upgrade->execFlow['17_3'] = array('functions' => 'processBugLinkBug'); +$config->upgrade->execFlow['17_4'] = array('functions' => 'rebuildFULLTEXT,updateSearchIndex', 'xxfunctions' => 'addAdminInviteField'); +$config->upgrade->execFlow['17_5'] = array('functions' => 'updateOSAndBrowserOfBug,addURPriv,updateStoryStatus,syncCase2Project'); +$config->upgrade->execFlow['17_6'] = array('functions' => 'updateStoryFile,convertTaskteam,convertEstToEffort,fixWeeklyReport,xuanSetOwnedByForGroups,xuanRecoverCreatedDates,xuanSetPartitionedMessageIndex'); +$config->upgrade->execFlow['17_6_1'] = array('functions' => 'updateProductView'); +$config->upgrade->execFlow['17_6_2'] = array('xxsqls' => "$appRoot/db/upgradexuanxuan6.4.sql"); +$config->upgrade->execFlow['17_8'] = array('functions' => 'xuanSetMuteForHiddenGroups,xuanNotifyGroupHiddenUsers,initShadowBuilds', 'xxsqls' => "$appRoot/db/upgradexuanxuan6.5.sql"); +$config->upgrade->execFlow['18_0_beta1'] = array('xxsqls' => "$appRoot/db/upgradexuanxuan6.6.sql"); +$config->upgrade->execFlow['18_0_beta3'] = array('functions' => 'updateMyBlocks'); +$config->upgrade->execFlow['18_1'] = array('functions' => 'insertMixStage'); +$config->upgrade->execFlow['18_2'] = array('functions' => 'setting-setSN'); +$config->upgrade->execFlow['18_3'] = array('functions' => 'changeBookToCustomLib,createDefaultDimension,convertDocCollect,addBIUpdateMark'); +$config->upgrade->execFlow['18_4_alpha1'] = array('functions' => 'setURSwitchStatus'); +$config->upgrade->execFlow['18_4'] = array('functions' => 'fixMissedFlowField', 'xxsqls' => "$appRoot/db/upgradexuanxuan7.1.sql,$appRoot/db/upgradexuanxuan7.2.beta.sql"); +$config->upgrade->execFlow['18_5'] = array('functions' => 'installIPD,updatePivotFieldsType,addCreateAction4Story'); +$config->upgrade->execFlow['18_6'] = array('functions' => 'removeProductLineRequired'); +$config->upgrade->execFlow['18_7'] = array('functions' => 'processHistoryDataForMetric,metric-updateMetricDate'); +$config->upgrade->execFlow['18_8'] = array('functions' => 'upgradeTesttaskMembers,deleteGeneralReportBlock,stopOldCron'); + +if(!empty($config->isINT)) +{ + unset($config->upgrade->execFlow['11_1']); + unset($config->upgrade->execFlow['12_1']); + unset($config->upgrade->execFlow['15_4']); + unset($config->upgrade->execFlow['11_4_1']['xxsqls']); + unset($config->upgrade->execFlow['11_6_5']['xxsqls']); + unset($config->upgrade->execFlow['15_0_rc3']['xxsqls']); + + $config->upgrade->execFlow['11_4_1']['functions'] = 'addPriv11_5'; + $config->upgrade->execFlow['16_4']['xxsqls'] = "$appRoot/db/xuanxuan.sql"; +} + +if($config->edition == 'max') +{ + $config->upgrade->execFlow['16_5']['functions'] .= ',moveResult2Node'; + $config->upgrade->execFlow['17_2']['functions'] = 'addReviewIssusApprovalData'; + $config->upgrade->execFlow['18_0_beta1']['functions'] = 'initReviewEfforts'; +} + +if($config->edition != 'open') +{ + $config->upgrade->execFlow['17_0_beta1']['functions'] = 'processViewFields'; + $config->upgrade->execFlow['17_0']['functions'] .= ',processFlowPosition'; + $config->upgrade->execFlow['17_4']['functions'] .= ',processCreatedInfo,processCreatedBy,updateApproval,addDefaultRuleToWorkflow,processReviewLinkages,addFlowActions,addFlowFields'; + $config->upgrade->execFlow['17_4']['params']['addFlowActions'] = array('biz7.4'); + $config->upgrade->execFlow['17_4']['params']['addFlowFields'] = array('biz7.4'); + $config->upgrade->execFlow['17_6_2']['functions'] = 'processFeedbackModule'; + $config->upgrade->execFlow['18_3']['functions'] .= ',processDataset,processChart,processReport,processDashboard'; + $config->upgrade->execFlow['18_4_beta1']['functions'] = 'processDeployStepAction,updateBISQL,checkPivotSQL'; +} + +if(in_array($this->config->edition, array('max', 'ipd'))) $config->upgrade->execFlow['18_7']['functions'] = 'processOldMetrics,processHistoryDataForMetric,metric-updateMetricDate'; + +$config->upgrade->execFlow['pro3_2_1'] = array('functions' => 'recordFinished'); +$config->upgrade->execFlow['pro3_3'] = array('functions' => 'toLowerTable', 'params' => array('toLowerTable' => array('pro'))); +$config->upgrade->execFlow['pro4_0'] = array('functions' => 'fixRepo'); +$config->upgrade->execFlow['pro7_0_beta'] = array('functions' => 'fixReport'); +$config->upgrade->execFlow['pro8_8'] = array('functions' => 'checkURAndSR'); +$config->upgrade->execFlow['pro10_0_2'] = array('functions' => 'fixReportLang'); +$config->upgrade->execFlow['pro10_2'] = array('functions' => 'addDefaultKanbanPri'); + +$config->upgrade->execFlow['biz2_3_1'] = array('functions' => 'adjustFeedbackViewData'); +$config->upgrade->execFlow['biz3_4'] = array('functions' => 'importBuildinModules'); +$config->upgrade->execFlow['biz3_5_alpha'] = array('functions' => 'addSubStatus'); +$config->upgrade->execFlow['biz3_5_beta'] = array('functions' => 'processSubTables'); +$config->upgrade->execFlow['biz3_6'] = array('functions' => 'addDefaultActions,importCaseLibModule,deleteBuildinFields'); +$config->upgrade->execFlow['biz3_6_1'] = array('functions' => 'addWorkflowActions,processWorkflowLayout,processWorkflowLabel,processWorkflowCondition'); +$config->upgrade->execFlow['biz3_7'] = array('functions' => 'processWorkflowFields'); +$config->upgrade->execFlow['biz3_7_2'] = array('functions' => 'processFlowStatus'); +$config->upgrade->execFlow['biz4_0_1'] = array('functions' => 'addMailtoFields'); +$config->upgrade->execFlow['biz4_0_3'] = array('functions' => 'updateAttendStatus,initView4WorkflowDatasource'); +$config->upgrade->execFlow['biz5_0'] = array('functions' => 'adjustPrivBiz5_0_1'); +$config->upgrade->execFlow['biz5_0_1'] = array('functions' => 'updateWorkflow4Execution'); +$config->upgrade->execFlow['biz5_2'] = array('functions' => 'addDefaultKanbanPri'); +$config->upgrade->execFlow['biz5_3_1'] = array('functions' => 'processFeedbackField,addFileFields,addReportActions'); +$config->upgrade->execFlow['biz6_4'] = array('functions' => 'importLiteModules'); + +if(!empty($config->isINT)) +{ + $config->upgrade->execFlow['biz3_0'] = array('xxfunctions' => 'syncXXHttpsConfig', 'xxsqls' => "$appRoot/db/upgradexuanxuan2.3.0.sql"); + $config->upgrade->execFlow['biz3_2_1'] = array('functions' => 'updateXX_11_5', 'xxsqls' => "$appRoot/db/upgradexuanxuan2.4.0.sql,$appRoot/db/upgradexuanxuan2.5.0.sql"); + $config->upgrade->execFlow['biz3_6_1']['xxsqls'] = "$appRoot/db/upgradexuanxuan3.1.1.sql"; +} + +$config->upgrade->execFlow['max2_2'] = array('functions' => 'addDefaultKanbanPri'); diff --git a/module/upgrade/control.php b/module/upgrade/control.php index f9c62006e0..0d9bba7ebe 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -122,7 +122,6 @@ class upgrade extends control if (!is_writable($this->app->getTmpRoot())) $writable = false; if(file_exists($this->app->getTmpRoot() . 'upgradeSqlLines')) @unlink($this->app->getTmpRoot() . 'upgradeSqlLines'); $confirmSql = $this->upgrade->getConfirm($fromVersion); - $confirmSql = str_replace('ENGINE=InnoDB', 'ENGINE=MyISAM', $confirmSql); $this->session->set('step', ''); $this->view->title = $this->lang->upgrade->confirm; @@ -164,6 +163,7 @@ class upgrade extends control $rawFromVersion = isset($_POST['fromVersion']) ? $this->post->fromVersion : $fromVersion; if(strpos($fromVersion, 'lite') !== false) $rawFromVersion = $this->config->upgrade->liteVersion[$fromVersion]; if(strpos($fromVersion, 'ipd') !== false) $rawFromVersion = $this->config->upgrade->ipdVersion[$fromVersion]; + $this->dao->begin(); $this->upgrade->execute($rawFromVersion); if(!$this->upgrade->isError()) @@ -920,7 +920,7 @@ class upgrade extends control { set_time_limit(0); $alterSQL = $this->upgrade->checkConsistency(); - $alterSQL = str_replace('ENGINE=InnoDB', 'ENGINE=MyISAM', $alterSQL); + $alterSQL = str_replace('ENGINE=MyISAM', 'ENGINE=InnoDB', $alterSQL); if(empty($alterSQL)) { if(!$netConnect) $this->locate(inlink('selectVersion')); diff --git a/module/upgrade/model.php b/module/upgrade/model.php index e7e2a4ce2d..3d5d3ad64b 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -15,6 +15,10 @@ class upgradeModel extends model { static $errors = array(); + public $fromVersion = ''; + + public $fromEdition = ''; + /** * Construct * @@ -91,6 +95,9 @@ class upgradeModel extends model $fromEdition = $this->getEditionByVersion($fromVersion); + $this->fromVersion = $fromVersion; + $this->fromEdition = $fromEdition; + /* If the 'current openVersion' is not equal the 'from openVersion', must update structure. */ $currentVersion = str_replace('.', '_', $this->config->version); @@ -110,13 +117,13 @@ class upgradeModel extends model foreach($versions as $openVersion => $chargedVersions) { $executedXuanxuan = false; + if($openVersion == '10_1') $executedXuanxuan = true; + if($openVersion == '16_4' && !empty($this->config->isINT)) $executedXuanxuan = true; /* Execute open. */ - if(str_replace('_', '.', $openVersion) == '10.1') $executedXuanxuan = true; - $this->saveLogs("Execute $openVersion"); $this->execSQL($this->getUpgradeFile(str_replace('_', '.', $openVersion))); - $this->executeOpen($openVersion, $fromEdition, $executedXuanxuan, $fromVersion); + $this->executeOpen($openVersion, $executedXuanxuan); /* Execute pro. */ foreach($chargedVersions['pro'] as $proVersion) @@ -154,570 +161,23 @@ class upgradeModel extends model $this->addSubStatus(); } } + + $this->loadModel('program')->refreshStats(true); + $this->loadModel('product')->refreshStats(true); + $this->deletePatch(); } /** * Process data for open source. * * @param string $openVersion - * @param string $fromEdition * @param bool $executedXuanxuan - * @param string $fromVersion * @access public * @return void */ - public function executeOpen($openVersion, $fromEdition, $executedXuanxuan, $fromVersion) + public function executeOpen($openVersion, $executedXuanxuan) { - switch($openVersion) - { - case '1_0beta': - $this->updateCompany(); - break; - case '1_2': - $this->updateUBB(); - $this->updateNL1_2(); - break; - case '1_3': - $this->updateNL1_3(); - $this->updateTasks(); - break; - case '2_2': - $this->updateCases(); - $this->updateActivatedCountOfBug(); - break; - case '3_0_beta1': - $this->updateAction(); - $this->setOrderData(); - break; - case '3_3': - $this->updateTaskAssignedTo(); - break; - case '4_0_beta2': - $this->updateProjectType(); - $this->updateEstimatePriv(); - break; - case '4_0_1': - $this->addPriv4_0_1(); - break; - case '4_1': - $this->addPriv4_1(); - $this->processTaskFinish(); - $this->deleteCompany(); - break; - case '5_2_1': - $this->mergeProjectGoalAndDesc(); - break; - case '6_0_beta1': - $this->toLowerTable(); - $this->fixBugOSInfo(); - $this->fixTaskFinishedBy(); - break; - case '6_0': - $this->fixDataIndex(); - break; - case '7_1': - $this->initOrder(); - break; - case '7_3': - $this->adjustPriv7_4_beta(); - break; - case '8_0_1': - $this->addPriv8_1(); - break; - case '8_1_3': - $this->addPriv8_2_beta(); - $this->adjustConfigSectionAndKey(); - break; - case '8_2_6': - $this->adjustDocModule(); - $this->moveDocContent(); - $this->adjustPriv8_3(); - break; - case '8_3_1': - $this->renameMainLib(); - $this->adjustPriv8_4(); - break; - case '9_0_beta': - $this->adjustPriv9_0(); - break; - case '9_0': - $this->fixProjectProductData(); - break; - case '9_0_1': - $this->addBugDeadlineToCustomFields(); - $this->adjustPriv9_0_1(); - break; - case '9_1_2': - $this->processCustomMenus(); - $this->adjustPriv9_2(); - break; - case '9_4': - $this->adjustPriv9_4(); - break; - case '9_5_1': - $this->initProjectStoryOrder(); - break; - case '9_6': - $this->fixDatatableColsConfig(); - break; - case '9_6_1': - $this->addLimitedGroup(); - break; - case '9_6_3': - $this->changeLimitedName(); - $this->adjustPriv9_7(); - $this->changeStoryWidth(); - break; - case '9_7': - $this->changeTeamFields(); - $this->moveData2Notify(); - break; - case '9_8': - $this->fixTaskFinishedInfo(); - break; - case '9_8_1': - $this->fixTaskAssignedTo(); - $this->fixProjectClosedInfo(); - $this->resetProductLine(); - break; - case '9_8_2': - $this->addUniqueKeyToTeam(); - break; - case '9_8_3': - $this->adjustPriv10_0_alpha(); - break; - case '10_0_alpha': - $this->fixProjectStatisticBlock(); - break; - case '10_0': - $this->fixStorySpecTitle(); - $this->removeUnlinkPriv();//Remove unlink privilege for story, bug and testcase module. - break; - case '10_1': - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'xuanxuan.sql'; - $this->execSQL($xuanxuanSql); - $executedXuanxuan = true; - case '10_3_1': - $this->removeCustomMenu(); - break; - case '10_4': - $this->changeTaskParentValue(); - break; - case '10_6': - if(!$executedXuanxuan) - { - $this->saveLogs('Execute 10_6'); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.1.0.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.2.0.sql'; - $this->execSQL($xuanxuanSql); - } - $this->initXuanxuan(); - break; - case '11_1': - if(empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.3.0.sql'; - $this->execSQL($xuanxuanSql); - } - $this->dao->update(TABLE_CONFIG)->set('value')->eq('off')->where('`key`')->eq('isHttps')->andWhere('`section`')->eq('xuanxuan')->andWhere('`value`')->eq('0')->exec(); - $this->dao->update(TABLE_CONFIG)->set('value')->eq('on')->where('`key`')->eq('isHttps')->andWhere('`section`')->eq('xuanxuan')->andWhere('`value`')->eq('1')->exec(); - } - break; - case '11_2': - $this->processDocLibAcl(); - break; - case '11_3': - $this->addPriv11_4(); - break; - case '11_4_1': - $this->addPriv11_5(); - if(empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.4.0.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.5.0.sql'; - $this->execSQL($xuanxuanSql); - } - $this->updateXX_11_5(); - } - break; - case '11_6_1': - $this->adjustWebhookType(); - $this->adjustPriv11_6_2(); - break; - case '11_6_3': - $this->adjustPriv11_6_4(); - break; - case '11_6_5': - $this->fixGroupAcl(); - $this->fixBugTypeList(); - $this->adjustPriv11_7(); - $this->rmEditorAndTranslateDir(); - $this->setConceptSetted(); - - if(empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.5.7.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan3.0.0-beta.1.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan3.0-beta3.sql'; - $this->execSQL($xuanxuanSql); - } - } - break; - case '11_7': - $this->adjustPriv12_0(); - break; - case '12_0_1': - $this->importRepoFromConfig(); - break; - case '12_1': - if(empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan3.1.1.sql'; - $this->execSQL($xuanxuanSql); - } - } - break; - case '12_3_3': - $this->addPriv12_3_3(); - $this->processImport2TaskBugs(); //Code for task #7552 - break; - case '12_4_2': - $this->fixFromCaseVersion(); - $this->initStoryOfPlan(); - break; - case '12_4_4': - $this->adjustPriv12_5(); - break; - case '12_5_3': - $this->adjustWhitelistOfProject(); - $this->adjustWhitelistOfProduct(); - $this->adjustPriv15_0(); - break; - case '15_0_rc1': - $this->adjustUserView(); - break; - case '15_0_rc3': - if(empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan3.3.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan4.0.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan4.0.beta2.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan4.0.beta3.sql'; - $this->execSQL($xuanxuanSql); - } - } - $this->updateLibType(); - $this->updateRunCaseStatus(); - $this->fix4TaskLinkProject(); - $this->fixExecutionTeam(); - break; - case '15_0': - $this->adjustBugOfProject(); - $this->processBuildTable(); - $this->updateProductVersion(); - break; - case '15_0_2': - $this->uniqueProjectAdmin(); - break; - case '15_2': - $this->processGitlabRepo(); - $this->processStoryFileType(); - $this->processProductDoc(); - $this->adjustPriv15_3(); - break; - case '15_3': - $this->adjustBugRequired(); - $this->processTesttaskDate(); - $this->processDocTempContent(); - break; - case '15_4': - if(empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan4.2.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan4.4.sql'; - $this->execSQL($xuanxuanSql); - } - } - break; - case '15_5': - $this->addDefaultKanbanPri(); - break; - case '15_7_1': - $this->updateObjectBranch(); - $this->updateProjectStories(); - $this->updateProjectLinkedBranch(); - break; - case '16_0_beta1': - $this->loadModel('api')->createDemoData($this->lang->api->zentaoAPI, commonModel::getSysURL() . $this->app->config->webRoot . 'api.php/v1', '16.0'); - break; - case '16_1': - $this->moveKanbanData(); - break; - case '16_2': - $this->updateSpaceTeam(); - $this->updateDocField(); - break; - case '16_4': - set_time_limit(0); - $this->updateActivatedDate(); - - if(!empty($this->config->isINT)) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'xuanxuan.sql'; - $this->execSQL($xuanxuanSql); - $executedXuanxuan = true; - } - else - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan4.6.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan5.1.sql'; - $this->execSQL($xuanxuanSql); - } - } - - switch($fromEdition) - { - case 'open': - $this->execSQL($this->getUpgradeFile('proinstall')); - case 'pro': - $this->execSQL($this->getUpgradeFile('bizinstall')); - case 'biz': - $this->execSQL($this->getUpgradeFile('maxinstall')); - $this->execSQL($this->getUpgradeFile('functions')); - } - - $this->updateGroup4Lite(); - break; - case '16_5': - $this->updateProjectStatus(); - $this->updateStoryReviewer($fromVersion); - - if($this->config->edition == 'max') $this->moveResult2Node(); - break; - case '17_0_beta1': - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan5.5.sql'; - $this->execSQL($xuanxuanSql); - } - - if($this->config->edition != 'open') $this->processViewFields(); - break; - case '17_0_beta2': - $this->changeStoryNeedReview(); - break; - case '17_0': - $this->replaceSetLanePriv(); - $this->updateProjectData(); - - if($this->config->edition != 'open') $this->processFlowPosition(); - break; - case '17_1': - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan5.6.sql'; - $this->execSQL($xuanxuanSql); - $this->xuanAddMessageIndexColumns(); - $this->xuanReindexMessages(); - $this->xuanUpdateLastReadMessageIndex(); - $this->xuanFixChatsWithoutLastRead(); - } - $this->moveProjectAdmins(); - $this->addStoryViewPriv(); - break; - case '17_2': - if($this->config->edition == 'max') $this->addReviewIssusApprovalData(); - break; - case '17_3': - $this->processBugLinkBug(); - break; - case '17_4': - $this->rebuildFULLTEXT(); - $this->updateSearchIndex(); - if(!$executedXuanxuan) - { - $table = $this->config->db->prefix . 'im_chat'; - $exists = $this->checkFieldsExists($table, 'adminInvite'); - if(!$exists) - { - $this->dbh->query("ALTER TABLE $table ADD `adminInvite` enum('0','1') NOT NULL DEFAULT '0' AFTER `mergedChats`"); - } - } - - if($this->config->edition != 'open') - { - $this->processCreatedInfo(); - $this->processCreatedBy(); - $this->updateApproval(); - $this->addDefaultRuleToWorkflow(); - $this->processReviewLinkages(); - $this->addFlowActions('biz7.4'); - $this->addFlowFields('biz7.4'); - } - break; - case '17_5': - $this->updateOSAndBrowserOfBug(); - $this->addURPriv(); - $this->updateStoryStatus(); - if(strpos($fromVersion, 'max') !== false) $this->syncCase2Project(); - break; - case '17_6': - $this->updateStoryFile(); - $this->convertTaskteam(); - $this->convertEstToEffort(); - $this->fixWeeklyReport(); - $this->xuanSetOwnedByForGroups(); - $this->xuanRecoverCreatedDates(); - $this->xuanSetPartitionedMessageIndex(); - break; - case '17_6_1': - $this->updateProductView(); - break; - case '17_6_2': - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan6.4.sql'; - $this->execSQL($xuanxuanSql); - } - if($this->config->edition != 'open') $this->processFeedbackModule(); - break; - case '17_8': - if(!$executedXuanxuan) - { - $table = $this->config->db->prefix . 'user'; - $clientStatusExists = $this->checkFieldsExists($table, 'clientStatus'); - $clientLangExists = $this->checkFieldsExists($table, 'clientLang'); - $pinyinExists = $this->checkFieldsExists($table, 'pinyin'); - - if(!$clientStatusExists) $this->dbh->query("ALTER TABLE $table ADD `clientStatus` varchar(10) NOT NULL DEFAULT 'zh-cn' AFTER `deleted`"); - if(!$clientLangExists) $this->dbh->query("ALTER TABLE $table ADD `clientLang` enum('0','1') enum('online','away','busy','offline','meeting') NOT NULL DEFAULT 'offline' AFTER `deleted`"); - if(!$pinyinExists) $this->dbh->query("ALTER TABLE $table ADD `pinyin` varchar(255) NOT NULL DEFAULT '' AFTER `realname`"); - - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan6.5.sql'; - $this->execSQL($xuanxuanSql); - } - $this->xuanSetMuteForHiddenGroups(); - $this->xuanNotifyGroupHiddenUsers(); - $this->initShadowBuilds(); - break; - case '18_0_beta1': - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan6.6.sql'; - $this->execSQL($xuanxuanSql); - } - - if($this->config->edition == 'max') $this->initReviewEfforts(); - break; - case '18_0_beta3': - $this->updateMyBlocks(); - break; - case '18_1': - $this->insertMixStage(); - break; - case '18_2': - $this->loadModel('setting')->setSN(); - break; - case '18_3': - $this->changeBookToCustomLib(); - $this->createDefaultDimension(); - $this->convertDocCollect(); - $this->addBIUpdateMark(); - - if($this->config->edition != 'open') - { - $this->processDataset(); - $this->processChart(); - $this->processReport(); - $this->processDashboard(); - } - break; - case '18_4_alpha1': - if($this->config->edition != 'open') $this->processDataset(); - $this->setURSwitchStatus($fromVersion); - break; - case '18_4_beta1': - if($this->config->edition != 'open') - { - $this->processDeployStepAction(); - $this->updateBISQL(); - $this->checkPivotSQL(); - } - break; - case '18_4': - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan7.1.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan7.2.beta.sql'; - $this->execSQL($xuanxuanSql); - } - - if($this->config->edition != 'open' and in_array($fromVersion, $this->config->upgrade->missedFlowFieldVersions)) - { - $this->fixMissedFlowField(); - } - break; - case '18_5': - $fromVersion = $this->loadModel('setting')->getItem('owner=system&module=common§ion=global&key=version'); - $ipdinstall = false; - - if(is_numeric($fromVersion[0]) and version_compare($fromVersion, '18.5', '<=')) $ipdinstall = true; - if(strpos($fromVersion, 'pro') !== false) $ipdinstall = true; - if(strpos($fromVersion, 'biz') !== false and version_compare($fromVersion, 'biz8.5', '<=')) $ipdinstall = true; - if(strpos($fromVersion, 'max') !== false and version_compare($fromVersion, 'max4.5', '<=')) $ipdinstall = true; - if($ipdinstall) $this->execSQL($this->getUpgradeFile('ipdinstall')); - - if($fromVersion == 'ipd1.0.beta1') $this->execSQL($this->getUpgradeFile('ipd1.0.beta1')); - - $this->loadModel('product')->refreshStats(true); - $this->loadModel('program')->refreshStats(true); - $this->updatePivotFieldsType(); - - if(in_array($fromVersion, array('18.5', 'biz8.5', 'max4.5'))) $this->addCreateAction4Story(); - break; - case '18_6': - $this->removeProductLineRequired(); - break; - case '18_7': - if(in_array($this->config->edition, array('max', 'ipd'))) $this->processOldMetrics(); - $this->processHistoryDataForMetric(); - $this->loadModel('metric')->updateMetricDate(); - break; - case '18_8': - /* Upgrade members for testtask. */ - $this->upgradeTesttaskMembers(); - $this->loadModel('program')->refreshStats(true); - $this->deleteGeneralReportBlock(); - /* Stop old cron. */ - touch($this->app->getCacheRoot() . 'restartcron'); - break; - } - - $this->deletePatch(); + $this->executeByConfig($openVersion, $executedXuanxuan); return true; } @@ -730,36 +190,10 @@ class upgradeModel extends model */ public function executePro($proVersion) { - switch($proVersion) - { - case 'pro1_1_1': - $this->execSQL($this->getUpgradeFile('pro1.1')); - break; - case 'pro3_2_1': - $this->recordFinished(); - break; - case 'pro3_3': - $this->toLowerTable('pro'); - break; - case 'pro4_0': - $this->fixRepo(); - break; - case 'pro7_0_beta': - $this->fixReport(); - break; - case 'pro8_3': - $this->execSQL($this->getUpgradeFile('pro8.2')); //Fix bug #1752. - break; - case 'pro8_8': - $this->checkURAndSR(); - break; - case 'pro10_0_2': - $this->fixReportLang(); - break; - case 'pro10_2': - $this->addDefaultKanbanPri(); - break; - } + if($proVersion == 'pro1_1_1') $this->execSQL($this->getUpgradeFile('pro1.1')); + if($proVersion == 'pro8_3') $this->execSQL($this->getUpgradeFile('pro8.2')); //Fix bug #1752. + + $this->executeByConfig($proVersion); } /** @@ -772,88 +206,7 @@ class upgradeModel extends model */ public function executeBiz($bizVersion, $executedXuanxuan) { - switch($bizVersion) - { - case 'biz2_3_1': - $this->adjustFeedbackViewData(); - break; - case 'biz3_0': - if(!empty($this->config->isINT) and !$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.3.0.sql'; - $this->execSQL($xuanxuanSql); - $this->dao->update(TABLE_CONFIG)->set('value')->eq('off')->where('`key`')->eq('isHttps')->andWhere('`section`')->eq('xuanxuan')->andWhere('`value`')->eq('0')->exec(); - $this->dao->update(TABLE_CONFIG)->set('value')->eq('on')->where('`key`')->eq('isHttps')->andWhere('`section`')->eq('xuanxuan')->andWhere('`value`')->eq('1')->exec(); - } - break; - case 'biz3_2_1': - if(!empty($this->config->isINT)) - { - if(!$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.4.0.sql'; - $this->execSQL($xuanxuanSql); - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan2.5.0.sql'; - $this->execSQL($xuanxuanSql); - } - $this->updateXX_11_5(); - } - break; - case 'biz3_4': - $this->importBuildinModules(); - break; - case 'biz3_5_alpha': - $this->addSubStatus(); - case 'biz3_5_beta': - $this->processSubTables(); - break; - case 'biz3_6': - $this->addDefaultActions(); - $this->importCaseLibModule(); - $this->deleteBuildinFields(); - break; - case 'biz3_6_1': - $this->addWorkflowActions(); - $this->processWorkflowLayout(); - $this->processWorkflowLabel(); - $this->processWorkflowCondition(); - if(!empty($this->config->isINT) and !$executedXuanxuan) - { - $xuanxuanSql = $this->app->getAppRoot() . 'db' . DS . 'upgradexuanxuan3.1.1.sql'; - $this->execSQL($xuanxuanSql); - } - break; - case 'biz3_7': - $this->processWorkflowFields(); - break; - case 'biz3_7_2': - $this->processFlowStatus(); - break; - case 'biz4_0_1': - $this->addMailtoFields(); - break; - case 'biz4_0_3': - $this->updateAttendStatus(); - $this->initView4WorkflowDatasource(); - break; - case 'biz5_0': - $this->adjustPrivBiz5_0_1(); - break; - case 'biz5_0_1': - $this->updateWorkflow4Execution(); - break; - case 'biz5_2': - $this->addDefaultKanbanPri(); - break; - case 'biz5_3_1': - $this->processFeedbackField(); - $this->addFileFields(); - $this->addReportActions(); - break; - case 'biz6_4': - $this->importLiteModules(); - break; - } + $this->executeByConfig($bizVersion, $executedXuanxuan); } /** @@ -865,12 +218,7 @@ class upgradeModel extends model */ public function executeMax($maxVersion) { - switch($maxVersion) - { - case 'max2_2': - $this->addDefaultKanbanPri(); - break; - } + $this->executeByConfig($maxVersion); } /** @@ -884,6 +232,57 @@ class upgradeModel extends model { } + /** + * Execute upgrade methods by config. + * + * @param string $version + * @param bool $executedXuanxuan + * @access public + * @return void + */ + public function executeByConfig($version, $executedXuanxuan = false) + { + $execConfig = zget($this->config->upgrade->execFlow, $version, array()); + $functions = zget($execConfig, 'functions', ''); + $params = zget($execConfig, 'params', array()); + $xxsqls = zget($execConfig, 'xxsqls', ''); + $xxfunctions = zget($execConfig, 'xxfunctions', ''); + + foreach(array_filter(explode(',', $functions)) as $function) $this->executeUpgradeMethod($function, zget($params, $function, array())); + + $needExecXX = !$executedXuanxuan; + if($openVersion == '10_1') $needExecXX = true; + if($openVersion == '16_4' && !empty($this->config->isINT)) $needExecXX = true; + + if($needExecXX) + { + foreach(array_filter(explode(',', $xxsqls)) as $sqlFile) $this->execSQL($sqlFile); + foreach(array_filter(explode(',', $xxfunctions)) as $function) $this->executeUpgradeMethod($function, zget($params, $function, array())); + } + } + + /** + * Execute single upgrade method. + * + * @param string $method + * @param array $params + * @access public + * @return void + */ + public function executeUpgradeMethod($method, $params) + { + $this->saveLogs("Run Method {$function}"); + + $class = $this; + if(str_contains($functions, '-')) + { + list($className, $function) = explode('-', $function); + $class= $this->loadModel($className); + } + + return call_user_func_array(array($class, $function), $params); + } + /** * Create the confirm contents. * @@ -2124,10 +1523,12 @@ class upgradeModel extends model if(!file_exists($sqlFile)) return false; $this->saveLogs('Run Method ' . __FUNCTION__); - $mysqlVersion = $this->loadModel('install')->getDatabaseVersion(); - $ignoreCode = '|1050|1054|1060|1091|1061|'; - $sqls = $this->parseToSqls($sqlFile); + static $mysqlVersion; + if($mysqlVersion === null) $mysqlVersion = $this->loadModel('install')->getDatabaseVersion(); + + $ignoreCode = '|1050|1054|1060|1091|1061|'; + $sqls = $this->parseToSqls($sqlFile); foreach($sqls as $sql) { if(empty($sql)) continue; @@ -6602,10 +6003,10 @@ class upgradeModel extends model * @access public * @return void */ - public function updateStoryReviewer($fromVersion) + public function updateStoryReviewer() { $isOldVersion = false; - $fromVersion = str_replace('_', '.', $fromVersion); + $fromVersion = str_replace('_', '.', $this->fromVersion); if(is_numeric($fromVersion[0]) and version_compare($fromVersion, '12.5.3', '<=')) { $isOldVersion = true; @@ -7463,6 +6864,8 @@ class upgradeModel extends model */ public function syncCase2Project() { + if(strpos($this->fromVersion, 'max') === false) return; + $linkStoryCases = $this->dao->select('id, story, version, product')->from(TABLE_CASE)->where('story')->ne('0')->fetchAll('id'); $linkProjectCases = $this->dao->select('`case`, project')->from(TABLE_PROJECTCASE)->where('`case`')->ne('0')->andWhere('project')->ne('0')->fetchGroup('case', 'project'); @@ -9482,17 +8885,16 @@ class upgradeModel extends model /** * Set UR switch status in feature switch. * - * @param string $fromVersion * @access public * @return bool */ - public function setURSwitchStatus($fromVersion) + public function setURSwitchStatus() { $this->saveLogs('Run Method ' . __FUNCTION__); - if(is_numeric($fromVersion[0]) and version_compare($fromVersion, '18.2', '>=')) return true; - if(strpos($fromVersion, 'biz') !== false and version_compare($fromVersion, 'biz8.2', '>=')) return true; - if(strpos($fromVersion, 'max') !== false and version_compare($fromVersion, 'max4.2', '>=')) return true; + if(is_numeric($this->fromVersion[0]) and version_compare($this->fromVersion, '18.2', '>=')) return true; + if(strpos($this->fromVersion, 'biz') !== false and version_compare($this->fromVersion, 'biz8.2', '>=')) return true; + if(strpos($this->fromVersion, 'max') !== false and version_compare($this->fromVersion, 'max4.2', '>=')) return true; $URSwitchStatus = $this->loadModel('setting')->getItem("owner=system&module=custom&key=URAndSR"); if(!$URSwitchStatus) @@ -9545,6 +8947,12 @@ class upgradeModel extends model } } + /** + * Check pivot SQL. + * + * @access public + * @return void + */ public function checkPivotSQL() { $this->loadModel('pivot'); @@ -9583,6 +8991,8 @@ class upgradeModel extends model */ public function fixMissedFlowField() { + if($this->config->edition == 'open' || !in_array($this->fromVersion, $this->config->upgrade->missedFlowFieldVersions)) return; + $this->loadModel('workflow'); $this->loadModel('workflowaction'); $this->loadModel('workflowlayout'); @@ -9747,6 +9157,8 @@ class upgradeModel extends model */ public function addCreateAction4Story() { + if(!in_array($this->fromVersion, array('18_5', 'biz8_5', 'max4_5'))) return; + $stories = $this->dao->select('id,product,openedBy,openedDate,vision')->from(TABLE_STORY)->where('openedDate')->ge('2023-07-12')->fetchAll('id'); foreach($stories as $story) { @@ -9849,11 +9261,23 @@ class upgradeModel extends model return !dao::isError(); } + /** + * Alias for processHistoryOfStory. + * + * @access public + * @return void + */ public function processHistoryDataForMetric() { $this->processHistoryOfStory(); } + /** + * Process history of story. + * + * @access public + * @return void + */ public function processHistoryOfStory() { $linked2releaseActions = $this->dao->select('objectID, extra, max(`date`) as date, action') @@ -9929,4 +9353,93 @@ class upgradeModel extends model return true; } + + /** + * Sync xuanxuan https config. + * + * @access public + * @return void + */ + public function syncXXHttpsConfig() + { + $this->dao->update(TABLE_CONFIG)->set('value')->eq('off')->where('`key`')->eq('isHttps')->andWhere('`section`')->eq('xuanxuan')->andWhere('`value`')->eq('0')->exec(); + $this->dao->update(TABLE_CONFIG)->set('value')->eq('on')->where('`key`')->eq('isHttps')->andWhere('`section`')->eq('xuanxuan')->andWhere('`value`')->eq('1')->exec(); + return true; + } + + /** + * Create demo API. + * + * @access public + * @return void + */ + public function createDemoAPI() + { + $this->loadModel('api')->createDemoData($this->lang->api->zentaoAPI, commonModel::getSysURL() . $this->app->config->webRoot . 'api.php/v1', '16.0'); + return true; + } + + /** + * Complete the database for different edition. + * + * @access public + * @return void + */ + public function completionAllSQL() + { + switch($this->fromEdition) + { + case 'open': + $this->execSQL($this->getUpgradeFile('proinstall')); + case 'pro': + $this->execSQL($this->getUpgradeFile('bizinstall')); + case 'biz': + $this->execSQL($this->getUpgradeFile('maxinstall')); + $this->execSQL($this->getUpgradeFile('functionss')); + } + } + + /** + * Add adminInvite field for xuanxuan. + * + * @access public + * @return void + */ + public function addAdminInviteField() + { + $table = $this->config->db->prefix . 'im_chat'; + $exists = $this->checkFieldsExists($table, 'adminInvite'); + if(!$exists) $this->dbh->exec("ALTER TABLE $table ADD `adminInvite` enum('0','1') NOT NULL DEFAULT '0' AFTER `mergedChats`"); + } + + /** + * Insetall IPD. + * + * @access public + * @return void + */ + public function insetallIPD() + { + $fromVersion = $this->fromVersion; + $ipdinstall = false; + + if(is_numeric($fromVersion[0]) and version_compare($fromVersion, '18.5', '<=')) $ipdinstall = true; + if(strpos($fromVersion, 'pro') !== false) $ipdinstall = true; + if(strpos($fromVersion, 'biz') !== false and version_compare($fromVersion, 'biz8.5', '<=')) $ipdinstall = true; + if(strpos($fromVersion, 'max') !== false and version_compare($fromVersion, 'max4.5', '<=')) $ipdinstall = true; + if($ipdinstall) $this->execSQL($this->getUpgradeFile('ipdinstall')); + + if($fromVersion == 'ipd1.0.beta1') $this->execSQL($this->getUpgradeFile('ipd1.0.beta1')); + } + + /** + * Stop old cron. + * + * @access public + * @return void + */ + public function stopOldCron() + { + touch($this->app->getCacheRoot() . 'restartcron'); + } } diff --git a/www/upgrade.php.tmp b/www/upgrade.php.tmp index 6d2eccafd7..ba88e4ac24 100644 --- a/www/upgrade.php.tmp +++ b/www/upgrade.php.tmp @@ -63,7 +63,7 @@ $app->setDebug(); /* Check the installed version is the latest or not. */ $config->installedVersion = $common->loadModel('setting')->getVersion(); -if(($config->version[0] == $config->installedVersion[0] or (is_numeric($config->version[0]) and is_numeric($config->installedVersion[0]))) and version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php')); +if(!$app->session->upgrading && ($config->version[0] == $config->installedVersion[0] or (is_numeric($config->version[0]) and is_numeric($config->installedVersion[0]))) and version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php')); /* If run in container, upgrade automatically. */ if($app->isContainer())