summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-02-09 13:29:08 +0100
committerGitHub <noreply@github.com>2017-02-09 13:29:08 +0100
commit4a5a3681d921adad8c4cb5bb29180514446ea2b9 (patch)
tree76c3b4069d8e866fd680273180b145a94b40b269 /lib/private
parented4633a5523b14271e1bef9f484bfc0ab4dccde4 (diff)
parent18d7701d09b90ff58e69aa63454fe830c31ef2e7 (diff)
downloadnextcloud-server-4a5a3681d921adad8c4cb5bb29180514446ea2b9.tar.gz
nextcloud-server-4a5a3681d921adad8c4cb5bb29180514446ea2b9.zip
Merge pull request #3184 from nextcloud/issue-3165
Prevent migration from ownCloud 11 to Nextcloud 12
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Updater.php36
1 files changed, 16 insertions, 20 deletions
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index a66d49941cd..3f4e54cf803 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -157,9 +157,9 @@ class Updater extends BasicEmitter {
/**
* Return version from which this version is allowed to upgrade from
*
- * @return string allowed previous version
+ * @return array allowed previous versions per vendor
*/
- private function getAllowedPreviousVersion() {
+ private function getAllowedPreviousVersions() {
// this should really be a JSON file
require \OC::$SERVERROOT . '/version.php';
/** @var array $OC_VersionCanBeUpgradedFrom */
@@ -182,26 +182,22 @@ class Updater extends BasicEmitter {
* Whether an upgrade to a specified version is possible
* @param string $oldVersion
* @param string $newVersion
- * @param string $allowedPreviousVersion
+ * @param array $allowedPreviousVersions
* @return bool
*/
- public function isUpgradePossible($oldVersion, $newVersion, $allowedPreviousVersion) {
- $allowedUpgrade = (version_compare($allowedPreviousVersion, $oldVersion, '<=')
- && (version_compare($oldVersion, $newVersion, '<=') || $this->config->getSystemValue('debug', false)));
-
- if ($allowedUpgrade) {
- return $allowedUpgrade;
+ public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) {
+ $version = explode('.', $oldVersion);
+ $majorMinor = $version[0] . '.' . $version[1];
+
+ $currentVendor = $this->config->getAppValue('core', 'vendor', '');
+ if ($currentVendor === 'nextcloud') {
+ return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
+ && (version_compare($oldVersion, $newVersion, '<=') ||
+ $this->config->getSystemValue('debug', false));
}
- // Upgrade not allowed, someone switching vendor?
- if ($this->getVendor() !== $this->config->getAppValue('core', 'vendor', '')) {
- $oldVersion = explode('.', $oldVersion);
- $newVersion = explode('.', $newVersion);
-
- return $oldVersion[0] === $newVersion[0] && $oldVersion[1] === $newVersion[1];
- }
-
- return false;
+ // Check if the instance can be migrated
+ return isset($allowedPreviousVersions[$currentVendor][$majorMinor]);
}
/**
@@ -215,8 +211,8 @@ class Updater extends BasicEmitter {
*/
private function doUpgrade($currentVersion, $installedVersion) {
// Stop update if the update is over several major versions
- $allowedPreviousVersion = $this->getAllowedPreviousVersion();
- if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersion)) {
+ $allowedPreviousVersions = $this->getAllowedPreviousVersions();
+ if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
}