diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-08-10 00:25:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-10 00:25:53 +0200 |
commit | 9fbdb0efe895f7cfe03f613cc6fa5daee9f99dfe (patch) | |
tree | 88cb3bee5f36ee82e15dd53792f3564dbf67f349 /lib | |
parent | 2b04b58d9a16d99acbcf8624ae0f01aa1c109de9 (diff) | |
parent | 5c343464799346a1caf0cd6540e7d6510df255c6 (diff) | |
download | nextcloud-server-9fbdb0efe895f7cfe03f613cc6fa5daee9f99dfe.tar.gz nextcloud-server-9fbdb0efe895f7cfe03f613cc6fa5daee9f99dfe.zip |
Merge pull request #529 from nextcloud/vendor-maintenance-downgrade
Allow downgrades of maintenance accross vendors
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Updater.php | 29 | ||||
-rw-r--r-- | lib/private/legacy/app.php | 2 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 0a6d9c9a31d..609e965bfad 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -184,6 +184,18 @@ class Updater extends BasicEmitter { } /** + * Return vendor from which this version was published + * + * @return string Get the vendor + */ + private function getVendor() { + // this should really be a JSON file + require \OC::$SERVERROOT . '/version.php'; + /** @var string $vendor */ + return (string) $vendor; + } + + /** * Whether an upgrade to a specified version is possible * @param string $oldVersion * @param string $newVersion @@ -191,8 +203,22 @@ class Updater extends BasicEmitter { * @return bool */ public function isUpgradePossible($oldVersion, $newVersion, $allowedPreviousVersion) { - return (version_compare($allowedPreviousVersion, $oldVersion, '<=') + $allowedUpgrade = (version_compare($allowedPreviousVersion, $oldVersion, '<=') && (version_compare($oldVersion, $newVersion, '<=') || $this->config->getSystemValue('debug', false))); + + if ($allowedUpgrade) { + return $allowedUpgrade; + } + + // 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; } /** @@ -279,6 +305,7 @@ class Updater extends BasicEmitter { // only set the final version if everything went well $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion())); + $this->config->setAppValue('core', 'vendor', $this->getVendor()); } } diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 5395d1daeee..2d5e5ba1932 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -989,7 +989,7 @@ class OC_App { $currentVersion = OC_App::getAppVersion($app); if ($currentVersion && isset($versions[$app])) { $installedVersion = $versions[$app]; - if (version_compare($currentVersion, $installedVersion, '>')) { + if (!version_compare($currentVersion, $installedVersion, '=')) { return true; } } |