summaryrefslogtreecommitdiffstats
path: root/lib/private/updater.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/updater.php')
-rw-r--r--lib/private/updater.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/private/updater.php b/lib/private/updater.php
index f73fa8ff655..71e9732c307 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -212,19 +212,26 @@ class Updater extends BasicEmitter {
}
/**
+ * Return version from which this version is allowed to upgrade from
+ *
+ * @return string allowed previous version
+ */
+ private function getAllowedPreviousVersion() {
+ // this should really be a JSON file
+ require \OC::$SERVERROOT . '/version.php';
+ return implode('.', $OC_VersionCanBeUpgradedFrom);
+ }
+
+ /**
* Whether an upgrade to a specified version is possible
* @param string $oldVersion
* @param string $newVersion
+ * @param string $allowedPreviousVersion
* @return bool
*/
- public function isUpgradePossible($oldVersion, $newVersion) {
- $oldVersion = explode('.', $oldVersion);
- $newVersion = explode('.', $newVersion);
-
- if($newVersion[0] > ($oldVersion[0] + 1) || $oldVersion[0] > $newVersion[0]) {
- return false;
- }
- return true;
+ public function isUpgradePossible($oldVersion, $newVersion, $allowedPreviousVersion) {
+ return (version_compare($allowedPreviousVersion, $oldVersion, '<=')
+ && version_compare($oldVersion, $newVersion, '<='));
}
/**
@@ -259,8 +266,9 @@ class Updater extends BasicEmitter {
*/
private function doUpgrade($currentVersion, $installedVersion) {
// Stop update if the update is over several major versions
- if (!self::isUpgradePossible($installedVersion, $currentVersion)) {
- throw new \Exception('Updates between multiple major versions are unsupported.');
+ $allowedPreviousVersion = $this->getAllowedPreviousVersion();
+ if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersion)) {
+ throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
}
// Update .htaccess files