mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-12 03:16:54 +01:00
Improved upgrade checks
This commit is contained in:
24
inc/init.php
24
inc/init.php
@@ -456,21 +456,25 @@ class SP_Init {
|
||||
}
|
||||
|
||||
$update = FALSE;
|
||||
$configVersion = SP_Config::getValue('version');
|
||||
$databaseVersion = SP_Config::getConfigValue('version');
|
||||
$appVersion = implode('.', SP_Util::getVersion());
|
||||
|
||||
if ( $configVersion != $appVersion ){
|
||||
SP_Config::setValue('version', $appVersion);
|
||||
$update = TRUE;
|
||||
}
|
||||
$configVersion = (int) str_replace('.', '', SP_Config::getValue('version'));
|
||||
$databaseVersion = (int) str_replace('.', '', SP_Config::getConfigValue('version'));
|
||||
$appVersion = (int) implode(SP_Util::getVersion());
|
||||
|
||||
if ( $databaseVersion != $appVersion && SP_Common::parseParams('g', 'nodbupgrade', 0) === 0){
|
||||
if ( self::checkMaintenanceMode(TRUE) && SP_Upgrade::doUpgrade() ){
|
||||
if ( $databaseVersion < $appVersion && SP_Common::parseParams('g', 'nodbupgrade', 0) === 0){
|
||||
if ( SP_Upgrade::needUpgrade($appVersion) && ! self::checkMaintenanceMode(TRUE) ){
|
||||
self::initError(_('La aplicación necesita actualizarse'), _('Contacte con el administrador'));
|
||||
}
|
||||
|
||||
if ( SP_Upgrade::doUpgrade($appVersion) ){
|
||||
SP_Config::setConfigValue('version', $appVersion);
|
||||
$update = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $configVersion < $appVersion ){
|
||||
SP_Config::setValue('version', $appVersion);
|
||||
$update = TRUE;
|
||||
}
|
||||
|
||||
if ( $update === TRUE ){
|
||||
$message['action'] = _('Actualización');
|
||||
|
||||
@@ -30,14 +30,15 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*/
|
||||
class SP_Upgrade {
|
||||
private static $result = array();
|
||||
private static $upgrade = array(110);
|
||||
|
||||
public static function doUpgrade() {
|
||||
$currentDBVersion = (int) str_replace('.', '', SP_Config::getConfigValue('version'));
|
||||
$version = (int) implode(SP_Util::getVersion());
|
||||
|
||||
if ($currentDBVersion < $version) {
|
||||
$resUpgrade = self::upgradeTo($version);
|
||||
}
|
||||
/**
|
||||
* @brief Inicia el proceso de actualización de la BBDD
|
||||
* @param int $version con la versión a actualizar
|
||||
* @returns bool
|
||||
*/
|
||||
public static function doUpgrade($version) {
|
||||
$resUpgrade = self::upgradeTo($version);
|
||||
|
||||
SP_Common::wrLogInfo(self::$result);
|
||||
|
||||
@@ -50,6 +51,19 @@ class SP_Upgrade {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Comprueba si es necesario actualizar la BBDD
|
||||
* @returns bool
|
||||
*/
|
||||
public static function needUpgrade($version){
|
||||
return ( in_array($version, self::$upgrade) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Actualiza la BBDD según la versión
|
||||
* @param int $version con la versión a actualizar
|
||||
* @returns bool
|
||||
*/
|
||||
private static function upgradeTo($version) {
|
||||
self::$result['action'] = _('Actualizar BBDD');
|
||||
|
||||
|
||||
@@ -276,8 +276,10 @@ function doLogin(){
|
||||
}
|
||||
|
||||
function doLogout() {
|
||||
if ( window.location.search != '' ){
|
||||
location.href = 'index.php' + window.location.search + '&logout=1';
|
||||
var url = window.location.search;
|
||||
|
||||
if ( url.length > 0 ){
|
||||
location.href = 'index.php' + url + '&logout=1';
|
||||
} else{
|
||||
location.href = 'index.php?logout=1';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user