summaryrefslogtreecommitdiffstats
path: root/lib/private/updater.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-09-18 17:45:30 +0200
committerLukas Reschke <lukas@owncloud.com>2014-09-18 17:56:06 +0200
commita71af58535338f72061d5dbe31289ad132d0fa3a (patch)
tree89f9bc6b18b9278292041cfa808bae1d4e27f79f /lib/private/updater.php
parenta543807d85d4b5a8a72cbcb50820ba09250feefd (diff)
downloadnextcloud-server-a71af58535338f72061d5dbe31289ad132d0fa3a.tar.gz
nextcloud-server-a71af58535338f72061d5dbe31289ad132d0fa3a.zip
Prevent updates between multiple major versions
Ref https://github.com/owncloud/core/issues/11078
Diffstat (limited to 'lib/private/updater.php')
-rw-r--r--lib/private/updater.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 1d52f9be374..a2aa8bf33e9 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -146,15 +146,37 @@ class Updater extends BasicEmitter {
}
/**
+ * Whether an upgrade to a specified version is possible
+ * @param string $oldVersion
+ * @param string $newVersion
+ * @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;
+ }
+
+ /**
* runs the update actions in maintenance mode, does not upgrade the source files
* except the main .htaccess file
*
* @param string $currentVersion current version to upgrade to
* @param string $installedVersion previous version from which to upgrade from
*
+ * @throws \Exception
* @return bool true if the operation succeeded, false otherwise
*/
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.');
+ }
+
// Update htaccess files for apache hosts
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
\OC_Setup::updateHtaccess();
@@ -235,7 +257,7 @@ class Updater extends BasicEmitter {
}
/**
- * @param string $version the oc version to check app compatibilty with
+ * @param string $version the oc version to check app compatibility with
*/
protected function checkAppUpgrade($version) {
$apps = \OC_App::getEnabledApps();