* [refac] fixed the bug that the version in the cache and database are inconsistent after upgrading.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user