protected function runPart2($messageStreamer) { // Upgrade process can take much time, because upgrade schema script. // Set timeout for upgrade to 12 hours. set_time_limit(12 * 60 * 60); UpgradeUtil::runPart2($messageStreamer); }
/** * Main control to handle the flow of upgrade * * @author KnowledgeTree Team * @param none * @access public * @return void */ public function step() { $this->loadNeeded(); switch ($this->response) { case 'next': $step_name = $this->_getStepName(); $res = $this->_runStepAction($step_name); if ($res == 'next') { $this->_proceed(); // Load next window } elseif ($res == 'upgrade') { $this->_runStepsUpgraders(); // Load landing $this->_proceed(); // Load next window } elseif ($res == 'confirm') { if (!$this->stepDisplayFirst()) { $this->stepConfirmation = true; } $this->_landing(); } elseif ($res == 'landing') { $this->_landing(); } else { } break; case 'previous': $this->_backward(); // Load previous page break; case 'install': $util = new UpgradeUtil(); $util->redirect('../wizard/index.php?step_name=installtype'); break; default: // TODO : handle silent $this->_landing(); break; } $this->stepAction->paintAction(); // Display step }
/** * Upgrade step two: */ public function actionStepTwo() { // Upgrade process can take much time, because upgrade schema script. // Set timeout for upgrade to 12 hours. set_time_limit(12 * 60 * 60); Yii::app()->gameHelper->muteScoringModelsOnSave(); $nextView = new UpgradeStepTwoCompleteView($this->getId(), $this->getModule()->getId()); $view = new InstallPageView($nextView); echo $view->render(); $template = ZurmoHtml::script("\$('#logging-table').prepend('{message}<br/>');"); $messageStreamer = new MessageStreamer($template); $messageStreamer->setExtraRenderBytes(4096); $messageStreamer->add(Zurmo::t('InstallModule', 'Starting upgrade process.')); UpgradeUtil::runPart2($messageStreamer); ForgetAllCacheUtil::forgetAllCaches(); echo ZurmoHtml::script('$("#progress-table").hide(); $("#upgrade-step-two").show();'); Yii::app()->gameHelper->unmuteScoringModelsOnSave(); }
private function processingUpdateFile($upgradeInfo, $updateFileList, $upgradeStep, $urlParam) { if (EnvUtil::getRequest("coverStart")) { $data["step"] = 4; $confirm = EnvUtil::getRequest("confirm"); $startUpgrade = EnvUtil::getRequest("startupgrade"); if (!$confirm) { if (EnvUtil::getRequest("ftpsetting")) { $param = array("step" => 4, "confirm" => "ftp"); if ($startUpgrade) { $param["startupgrade"] = 1; } $data["data"]["status"] = "ftpsetup"; $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge($param, $urlParam)); $this->ajaxReturn($data, "json"); } if ($upgradeInfo["isupdatedb"]) { $fileList = array("data/update.php"); $checkUpdateFileList = array_merge($fileList, $updateFileList); } else { $checkUpdateFileList = $updateFileList; } if (FileUtil::checkFolderPerm($checkUpdateFileList)) { $confirm = "file"; } else { $data["data"]["status"] = "no_access"; $data["data"]["msg"] = Ibos::lang("Upgrade cannot access file"); $data["data"]["retryUrl"] = $this->createUrl("upgrade/index", array_merge(array("step" => 4), $urlParam)); $data["data"]["ftpUrl"] = $this->createUrl("upgrade/index", array_merge(array("step" => 4, "ftpsetting" => 1), $urlParam)); $this->ajaxReturn($data, "json"); } } $ftpParam = array(); $ftpSetup = EnvUtil::getRequest("ftpsetup"); if ($ftpSetup) { foreach ($ftpSetup as $key => $value) { $ftpParam["ftp[{$key}]"] = $value; } } if (!$startUpgrade) { if (!EnvUtil::getRequest("backfile")) { $param = array("step" => 4, "backfile" => 1, "confirm" => $confirm); $data["data"]["status"] = "upgrade_backuping"; $data["data"]["msg"] = Ibos::lang("Upgrade backuping"); $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge($ftpParam, $param, $urlParam)); $this->ajaxReturn($data, "json"); } foreach ($updateFileList as $updateFile) { $destFile = PATH_ROOT . "/" . $updateFile; $backFile = PATH_ROOT . "/data/back/IBOS" . VERSION . " Release[" . VERSION_DATE . "]/" . $updateFile; if (is_file($destFile)) { if (!UpgradeUtil::copyFile($destFile, $backFile, "file")) { $data["data"]["status"] = "upgrade_backup_error"; $data["data"]["msg"] = Ibos::lang("Upgrade backup error"); $this->ajaxReturn($data, "json"); } } } $data["data"]["status"] = "upgrade_backup_complete"; $data["data"]["msg"] = Ibos::lang("Upgrade backup complete"); $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge(array("step" => 4, "startupgrade" => 1, "confirm" => $confirm), $ftpParam, $urlParam)); $this->ajaxReturn($data, "json"); } $param = array("step" => 4, "startupgrade" => 1); $url = $this->createUrl("upgrade/index", array_merge($param, $urlParam, $ftpParam, array("confirm" => $confirm))); $ftpUrl = $this->createUrl("upgrade/index", array_merge($param, $urlParam, array("ftpsetting" => 1))); foreach ($updateFileList as $updateFile) { $srcFile = PATH_ROOT . "/data/update/IBOS" . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/" . $updateFile; if ($confirm == "ftp") { $destFile = $updateFile; } else { $destFile = PATH_ROOT . "/" . $updateFile; } if (!UpgradeUtil::copyFile($srcFile, $destFile, $confirm)) { Cache::model()->deleteByPk("upgrade_step"); Cache::model()->deleteByPk("upgrade_run"); $data["data"]["ftpUrl"] = $ftpUrl; $data["data"]["retryUrl"] = $url; if ($confirm == "ftp") { $data["data"]["status"] = "upgrade_ftp_upload_error"; $data["data"]["msg"] = Ibos::lang("Upgrade ftp upload error", "", array("{file}" => $updateFile)); } else { $data["data"]["status"] = "upgrade_copy_error"; $data["data"]["msg"] = Ibos::lang("Upgrade copy error", "", array("{file}" => $updateFile)); } $this->ajaxReturn($data, "json"); } } if ($upgradeInfo["isupdatedb"]) { $dbUpdateFileArr = array("update.php"); foreach ($dbUpdateFileArr as $dbUpdateFile) { $srcFile = PATH_ROOT . "/data/update/IBOS" . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/" . $dbUpdateFile; $dbUpdateFile = $dbUpdateFile == "update.php" ? "data/update.php" : $dbUpdateFile; if ($confirm == "ftp") { $destFile = $dbUpdateFile; } else { $destFile = PATH_ROOT . "/" . $dbUpdateFile; } if (!UpgradeUtil::copyFile($srcFile, $destFile, $confirm)) { $data["data"]["ftpUrl"] = $ftpUrl; $data["data"]["retryUrl"] = $url; if ($confirm == "ftp") { $data["data"]["status"] = "upgrade_ftp_upload_error"; $data["data"]["msg"] = Ibos::lang("Upgrade ftp upload error", "", array("{file}" => $dbUpdateFile)); } else { $data["data"]["status"] = "upgrade_copy_error"; $data["data"]["msg"] = Ibos::lang("Upgrade copy error", "", array("{file}" => $dbUpdateFile)); } $this->ajaxReturn($data, "json"); } } $upgradeStep["step"] = 4; Cache::model()->add(array("cachekey" => "upgrade_step", "cachevalue" => serialize($upgradeStep), "dateline" => TIMESTAMP), false, true); $dbReturnUrl = $this->createUrl("upgrade/index", array_merge(array("step" => 5), $urlParam)); $param = array("step" => "prepare", "from" => rawurlencode($dbReturnUrl), "frommd5" => md5(rawurlencode($dbReturnUrl) . Ibos::app()->setting->get("config/security/authkey"))); $data["data"]["status"] = "upgrade_database"; $data["data"]["url"] = "data/update.php?" . http_build_query($param); $data["data"]["msg"] = Ibos::lang("Upgrade file successful"); $this->ajaxReturn($data, "json"); } $data["data"]["status"] = "upgrade_file_successful"; $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge(array("step" => 5), $urlParam)); $data["step"] = 5; $this->ajaxReturn($data, "json"); } else { UpgradeUtil::recordStep(4); $coverUrl = $this->createUrl("upgrade/index", array_merge(array("step" => 4), $urlParam)); $this->render("upgradeCover", array("coverUrl" => $coverUrl)); } }