Throw exception on downgrade attempt

This commit is contained in:
Vincent Petry 2015-08-30 18:03:33 +02:00
parent 2b08659f7d
commit d5b0b55eef
1 changed files with 5 additions and 1 deletions

View File

@ -1448,8 +1448,12 @@ class OC_Util {
if ($config->getSystemValue('installed', false)) {
$installedVersion = $config->getSystemValue('version', '0.0.0');
$currentVersion = implode('.', OC_Util::getVersion());
if (version_compare($currentVersion, $installedVersion, '>')) {
$versionDiff = version_compare($currentVersion, $installedVersion);
if ($versionDiff > 0) {
return true;
} else if ($versionDiff < 0) {
// downgrade attempt, throw exception
throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
}
// also check for upgrades for apps (independently from the user)