diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 03af29a265..d112ebe7f9 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -2831,6 +2831,17 @@ class baseRouter fwrite($fh, "\n"); fclose($fh); } + + /** + * Check app if it is run in a container. + * + * @access public + * @return bool + */ + public function isContainer() + { + return strtolower(getenv('IS_CONTAINER')) == 'true'; + } } /** diff --git a/www/upgrade.php.tmp b/www/upgrade.php.tmp index cb16f99203..a2f2165848 100644 --- a/www/upgrade.php.tmp +++ b/www/upgrade.php.tmp @@ -65,6 +65,19 @@ $app->setDebug(); $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 run in container, upgrade automatically. */ +if($app->isContainer()) +{ + $upgradeModel = $common->loadModel('upgrade'); + $alterSQL = $upgradeModel->checkConsistency(); + if(!empty($alterSQL)) $upgradeModel->dao->query("SET @@sql_mode= '';" . $alterSQL); + + $config->set('default.method', 'execute'); + $app->session->set('upgrading', true); + $app->session->set('step', ''); + $app->post->set('fromVersion', str_replace( '.', '_', strtolower($config->installedVersion))); +} + /* Run it. */ $app->parseRequest(); if($common->checkUpgradeStatus()) $app->loadModule();