* [refac] fixed the bug that the version in the cache and database are inconsistent after upgrading.

This commit is contained in:
liugang
2025-01-26 15:57:43 +08:00
committed by 刘刚
parent cb64bdf272
commit 11fdc932ec
2 changed files with 18 additions and 2 deletions
+17
View File
@@ -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
View File
@@ -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);