* Add codes to control if it can be upgraded automatically or has a valid safe file.

This commit is contained in:
dingguodong
2023-12-26 08:48:31 +08:00
committed by tanghucheng
parent 74cc2a1c67
commit a57aaed716
3 changed files with 25 additions and 1 deletions
+22
View File
@@ -3149,6 +3149,28 @@ class baseRouter
return strtolower(getenv('IS_CONTAINER')) == 'true';
}
/**
* Check app if it can be upgraded automatically.
*
* @access public
* @return bool
*/
public function canAutoUpgrade()
{
return strtolower(getenv('ZT_AUTO_UPGRADE')) == 'true';
}
/**
* Check app if it need check safe file.
*
* @access public
* @return bool
*/
public function hasValidSafeFile()
{
return strtolower(getenv('ZT_CHECK_SAFE_FILE')) == 'true';
}
/**
* Get main file and ext files.
*
+2
View File
@@ -2474,6 +2474,8 @@ EOF;
{
if($this->app->isContainer()) return false;
if($this->app->hasValidSafeFile()) return false;
if($this->app->getModuleName() == 'upgrade' and $this->session->upgrading) return false;
$statusFile = $this->app->getAppRoot() . 'www' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'ok.txt';
+1 -1
View File
@@ -66,7 +66,7 @@ $config->installedVersion = $common->loadModel('setting')->getVersion();
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())
if($app->isContainer() || $app->canAutoUpgrade())
{
$upgradeModel = $common->loadModel('upgrade');
$alterSQL = $upgradeModel->checkConsistency();