summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-01-20 17:47:45 +0100
committerJoas Schilling <coding@schilljs.com>2017-01-23 12:04:46 +0100
commit18d7701d09b90ff58e69aa63454fe830c31ef2e7 (patch)
treef486150b4c0c1fc09e80e5984048defa6950d080 /lib/private
parent33ca69166a41188a6e19849243c5e1c2a16860dc (diff)
downloadnextcloud-server-18d7701d09b90ff58e69aa63454fe830c31ef2e7.tar.gz
nextcloud-server-18d7701d09b90ff58e69aa63454fe830c31ef2e7.zip
Prevent migration from ownCloud 11 to Nextcloud 12
Signed-off-by: Joas Schilling <coding@schilljs.com>
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.');
}