mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 16:36:59 +01:00
* [FIX] Upgrade not needed when updating between v3 releases. Thanks to @vmarion89 for the feedback. Closes #1210
This commit is contained in:
@@ -141,9 +141,11 @@ final class Init extends ModuleBase
|
||||
*/
|
||||
private function checkUpgrade()
|
||||
{
|
||||
UpgradeUtil::fixAppUpgrade($this->configData, $this->config);
|
||||
|
||||
if ($this->configData->getUpgradeKey()
|
||||
|| (UpgradeDatabaseService::needsUpgrade($this->configData->getDatabaseVersion()) ||
|
||||
UpgradeAppService::needsUpgrade(UpgradeUtil::fixVersionNumber($this->configData->getAppVersion())))
|
||||
UpgradeAppService::needsUpgrade($this->configData->getAppVersion()))
|
||||
) {
|
||||
$this->config->generateUpgradeKey();
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
|
||||
use SP\Modules\Web\Controllers\Traits\JsonTrait;
|
||||
use SP\Services\Upgrade\UpgradeAppService;
|
||||
use SP\Services\Upgrade\UpgradeDatabaseService;
|
||||
use SP\Services\Upgrade\UpgradeUtil;
|
||||
|
||||
/**
|
||||
* Class UpgradeController
|
||||
@@ -64,14 +63,19 @@ final class UpgradeController extends ControllerBase
|
||||
public function upgradeAction()
|
||||
{
|
||||
if ($this->request->analyzeBool('chkConfirm', false) === false) {
|
||||
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('The updating need to be confirmed'));
|
||||
return $this->returnJsonResponse(
|
||||
JsonResponse::JSON_ERROR,
|
||||
__u('The updating need to be confirmed')
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->request->analyzeString('key') !== $this->configData->getUpgradeKey()) {
|
||||
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Wrong security code'));
|
||||
return $this->returnJsonResponse(
|
||||
JsonResponse::JSON_ERROR,
|
||||
__u('Wrong security code')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$dbVersion = $this->configData->getDatabaseVersion();
|
||||
$dbVersion = empty($dbVersion) ? '0.0' : $dbVersion;
|
||||
@@ -81,15 +85,21 @@ final class UpgradeController extends ControllerBase
|
||||
->upgrade($dbVersion, $this->configData);
|
||||
}
|
||||
|
||||
if (UpgradeAppService::needsUpgrade(UpgradeUtil::fixVersionNumber($this->configData->getAppVersion()))) {
|
||||
$appVersion = $this->configData->getAppVersion();
|
||||
|
||||
if (UpgradeAppService::needsUpgrade($appVersion)) {
|
||||
$this->dic->get(UpgradeAppService::class)
|
||||
->upgrade(UpgradeUtil::fixVersionNumber($this->configData->getAppVersion()), $this->configData);
|
||||
->upgrade($appVersion, $this->configData);
|
||||
}
|
||||
|
||||
$this->configData->setUpgradeKey(null);
|
||||
$this->config->saveConfig($this->configData, false);
|
||||
|
||||
return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Application successfully updated'), [__u('You will be redirected to log in within 5 seconds')]);
|
||||
return $this->returnJsonResponse(
|
||||
JsonResponse::JSON_SUCCESS,
|
||||
__u('Application successfully updated'),
|
||||
[__u('You will be redirected to log in within 5 seconds')]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
processException($e);
|
||||
|
||||
|
||||
@@ -280,12 +280,15 @@ final class Init extends ModuleBase
|
||||
|
||||
/**
|
||||
* Comprobar si es necesario actualizar componentes
|
||||
* @throws \SP\Storage\File\FileException
|
||||
*/
|
||||
private function checkUpgrade()
|
||||
{
|
||||
UpgradeUtil::fixAppUpgrade($this->configData, $this->config);
|
||||
|
||||
return $this->configData->getUpgradeKey()
|
||||
|| (UpgradeDatabaseService::needsUpgrade($this->configData->getDatabaseVersion()) ||
|
||||
UpgradeAppService::needsUpgrade(UpgradeUtil::fixVersionNumber($this->configData->getAppVersion())));
|
||||
UpgradeAppService::needsUpgrade($this->configData->getAppVersion()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,9 +54,9 @@ final class Installer extends Service
|
||||
/**
|
||||
* sysPass' version and build number
|
||||
*/
|
||||
const VERSION = [3, 0, 2];
|
||||
const VERSION = [3, 0, 3];
|
||||
const VERSION_TEXT = '3.0';
|
||||
const BUILD = 19012401;
|
||||
const BUILD = 19012402;
|
||||
|
||||
/**
|
||||
* @var DatabaseSetupInterface
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
namespace SP\Services\Upgrade;
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Config\ConfigData;
|
||||
use SP\Util\PasswordUtil;
|
||||
use SP\Util\VersionUtil;
|
||||
|
||||
/**
|
||||
* Class UpgradeUtil
|
||||
@@ -76,4 +78,22 @@ final class UpgradeUtil
|
||||
$configData->setMaintenance(true);
|
||||
$config->saveConfig($configData, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigData $configData
|
||||
* @param Config $config
|
||||
* @throws \SP\Storage\File\FileException
|
||||
*/
|
||||
public static function fixAppUpgrade(ConfigData $configData, Config $config)
|
||||
{
|
||||
// Fixes bug in 3.0.X version where some updates weren't applied
|
||||
// when upgrading from v2
|
||||
// $dbVersion is always '' when upgrading from v2
|
||||
if (!empty($configData->getDatabaseVersion())
|
||||
&& empty($configData->getAppVersion())
|
||||
) {
|
||||
$configData->setAppVersion(VersionUtil::getVersionStringNormalized());
|
||||
$config->saveConfig($configData, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user