diff --git a/config/config.sample.php b/config/config.sample.php index e91ca40293d8b..8bb0fcb5c2bcd 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -500,6 +500,11 @@ */ 'updater.server.url' => 'https://updates.nextcloud.org/server/', +/** + * Release channel to use for updates + */ +'updater.release.channel' => 'stable', + /** * Is Nextcloud connected to the Internet or running in a closed network? */ diff --git a/lib/private/repair.php b/lib/private/repair.php index 098d4e7eb9369..a7c451c123938 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -37,6 +37,7 @@ use OC\Repair\CopyRewriteBaseToConfig; use OC\Repair\DropOldJobs; use OC\Repair\EncryptionCompatibility; +use OC\Repair\MoveChannelToSystemConfig; use OC\Repair\OldGroupMembershipShares; use OC\Repair\RemoveGetETagEntries; use OC\Repair\SqliteAutoincrement; @@ -118,6 +119,7 @@ public static function getRepairSteps() { new UpdateOutdatedOcsIds(\OC::$server->getConfig()), new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), new AvatarPermissions(\OC::$server->getDatabaseConnection()), + new MoveChannelToSystemConfig(\OC::$server->getConfig()), ]; } diff --git a/lib/private/repair/movechanneltosystemconfig.php b/lib/private/repair/movechanneltosystemconfig.php new file mode 100644 index 0000000000000..edc5748a6e7d1 --- /dev/null +++ b/lib/private/repair/movechanneltosystemconfig.php @@ -0,0 +1,51 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OC\Repair; + +use OC\Hooks\BasicEmitter; +use OCP\IConfig; + +/** + * Class MoveChannelToSystemConfig moves the defined OC_Channel in the app config + * to the system config to be compatible with the Nextcloud updater. + * + * @package OC\Repair + */ +class MoveChannelToSystemConfig extends BasicEmitter implements \OC\RepairStep { + /** @var IConfig */ + private $config; + + public function __construct(IConfig $config) { + $this->config = $config; + } + + public function getName() { + return 'Moves the stored release channel to the config file'; + } + + public function run() { + $channel = $this->config->getAppValue('core', 'OC_Channel', ''); + if($channel !== '') { + $this->config->setSystemValue('updater.release.channel', $channel); + $this->config->deleteAppValue('core', 'OC_Channel'); + } + } +} diff --git a/lib/private/util.php b/lib/private/util.php index b2ef5b463e794..74a944e085051 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -384,7 +384,8 @@ public static function getEditionString() { } /** - * @description get the update channel of the current installed of ownCloud. + * Get the currently configured release channel + * * @return string */ public static function getChannel() { @@ -421,7 +422,7 @@ private static function loadVersion() { // Allow overriding update channel if (\OC::$server->getSystemConfig()->getValue('installed', false)) { - $channel = \OC::$server->getAppConfig()->getValue('core', 'OC_Channel'); + $channel = \OC::$server->getConfig()->getSystemValue('updater.release.channel', null); } else { /** @var $OC_Channel string */ $channel = $OC_Channel; diff --git a/lib/public/util.php b/lib/public/util.php index 82c8cdbca7efe..bed36e0c4bea6 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -79,8 +79,8 @@ public static function getVersion() { */ public static function setChannel($channel) { //Flush timestamp to reload version.php + \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); \OC::$server->getSession()->set('OC_Version_Timestamp', 0); - \OC::$server->getAppConfig()->setValue('core', 'OC_Channel', $channel); } /**