diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 9c61a48c07..e969356383 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -3524,6 +3524,23 @@ class baseRouter return $installed; } + + /** + * 检查是否需要升级。如果需要升级并且开启了缓存,清空缓存以避免直接执行 SQL 语句导致数据不一致。 + * Check if need upgrade. If need upgrade and cache is open, clear the cache to avoid data inconsistency caused by direct execution of SQL statements. + * + * @access public + * @return bool + */ + public function checkNeedUpgrade() + { + $installedVersion = $this->getInstalledVersion(); + if($installedVersion == $this->config->version) return false; + + if(!empty($this->cache)) $this->cache->clear(); + + return true; + } } /** diff --git a/www/index.php b/www/index.php index 0cdc609056..97a9fdd47c 100644 --- a/www/index.php +++ b/www/index.php @@ -36,8 +36,7 @@ $app = router::createApp('pms', dirname(dirname(__FILE__)), 'router'); if(!$app->checkInstalled()) die(header('location: install.php')); /* Check for need upgrade. */ -$config->installedVersion = $app->getInstalledVersion(); -if($config->version != $config->installedVersion) die(header('location: upgrade.php')); +if($app->checkNeedUpgrade()) die(header('location: upgrade.php')); /* Run the app. */ $app->setStartTime($startTime);