diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-07 16:03:36 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-07 16:03:36 +0100 |
commit | 9ca670f94f8598042f8dade216e0b1f67a8631c8 (patch) | |
tree | 1ff9cb3d9533141677eb1082d01edc2e3bc5aae4 /lib/private | |
parent | 601457d2217ec1ed18b49061e38d4cda3703c9f6 (diff) | |
parent | fd7ed939378d4c52218b75b1ef81773963163458 (diff) | |
download | nextcloud-server-9ca670f94f8598042f8dade216e0b1f67a8631c8.tar.gz nextcloud-server-9ca670f94f8598042f8dade216e0b1f67a8631c8.zip |
Merge pull request #21505 from owncloud/allow-downgrades-for-brave-developers
Allow downgrades for our brave developers, that switch between branches
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/updater.php | 2 | ||||
-rw-r--r-- | lib/private/util.php | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/private/updater.php b/lib/private/updater.php index 04f8dcf7226..9ec72bab2f9 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -256,7 +256,7 @@ class Updater extends BasicEmitter { */ public function isUpgradePossible($oldVersion, $newVersion, $allowedPreviousVersion) { return (version_compare($allowedPreviousVersion, $oldVersion, '<=') - && version_compare($oldVersion, $newVersion, '<=')); + && (version_compare($oldVersion, $newVersion, '<=') || $this->config->getSystemValue('debug', false))); } /** diff --git a/lib/private/util.php b/lib/private/util.php index c9738b29ca1..6a9980fc129 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1483,6 +1483,7 @@ class OC_Util { * * @param \OCP\IConfig $config * @return bool whether the core or any app needs an upgrade + * @throws \OC\HintException When the upgrade from the given version is not allowed */ public static function needUpgrade(\OCP\IConfig $config) { if ($config->getSystemValue('installed', false)) { @@ -1491,6 +1492,19 @@ class OC_Util { $versionDiff = version_compare($currentVersion, $installedVersion); if ($versionDiff > 0) { return true; + } else if ($config->getSystemValue('debug', false) && $versionDiff < 0) { + // downgrade with debug + $installedMajor = explode('.', $installedVersion); + $installedMajor = $installedMajor[0] . '.' . $installedMajor[1]; + $currentMajor = explode('.', $currentVersion); + $currentMajor = $currentMajor[0] . '.' . $currentMajor[1]; + if ($installedMajor === $currentMajor) { + // Same major, allow downgrade for developers + return true; + } else { + // downgrade attempt, throw exception + throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); + } } 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 . ')'); |