Skip to content

Commit 24ce6da

Browse files
committed
Keep group restrictions when reenabling apps after an update
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 1ea5983 commit 24ce6da

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

lib/private/App/AppManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ public function disableApp($appId, $automaticDisabled = false) {
391391
}
392392

393393
if ($automaticDisabled) {
394-
$this->autoDisabledApps[] = $appId;
394+
$previousSetting = $this->appConfig->getValue($appId, 'enabled', 'yes');
395+
if ($previousSetting !== 'yes' && $previousSetting !== 'no') {
396+
$previousSetting = json_decode($previousSetting, true);
397+
}
398+
$this->autoDisabledApps[$appId] = $previousSetting;
395399
}
396400

397401
unset($this->installedAppsCache[$appId]);

lib/private/Updater.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@
4040
*/
4141
namespace OC;
4242

43+
use OC\App\AppManager;
4344
use OC\DB\Connection;
4445
use OC\DB\MigrationService;
4546
use OC\Hooks\BasicEmitter;
4647
use OC\IntegrityCheck\Checker;
4748
use OC_App;
49+
use OCP\App\IAppManager;
4850
use OCP\HintException;
4951
use OCP\IConfig;
5052
use OCP\ILogger;
@@ -265,9 +267,12 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo
265267
// Update the appfetchers version so it downloads the correct list from the appstore
266268
\OC::$server->getAppFetcher()->setVersion($currentVersion);
267269

270+
/** @var IAppManager|AppManager $appManager */
271+
$appManager = \OC::$server->getAppManager();
272+
268273
// upgrade appstore apps
269-
$this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
270-
$autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps();
274+
$this->upgradeAppStoreApps($appManager->getInstalledApps());
275+
$autoDisabledApps = $appManager->getAutoDisabledApps();
271276
$this->upgradeAppStoreApps($autoDisabledApps, true);
272277

273278
// install new shipped apps on upgrade
@@ -400,7 +405,7 @@ private function isCodeUpgrade(): bool {
400405
* @throws \Exception
401406
*/
402407
private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false): void {
403-
foreach ($disabledApps as $app) {
408+
foreach ($disabledApps as $app => $previousEnableSetting) {
404409
try {
405410
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
406411
if ($this->installer->isUpdateAvailable($app)) {
@@ -411,7 +416,11 @@ private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false
411416

412417
if ($reenable) {
413418
$ocApp = new \OC_App();
414-
$ocApp->enable($app);
419+
if (!empty($previousEnableSetting)) {
420+
$ocApp->enable($app, $previousEnableSetting);
421+
} else {
422+
$ocApp->enable($app);
423+
}
415424
}
416425
} catch (\Exception $ex) {
417426
$this->log->error($ex->getMessage(), [

lib/public/App/IAppManager.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ public function getAlwaysEnabledApps();
182182
*/
183183
public function getEnabledAppsForGroup(IGroup $group): array;
184184

185-
/**
186-
* @return array
187-
* @since 17.0.0
188-
*/
189-
public function getAutoDisabledApps(): array;
190-
191185
/**
192186
* @param String $appId
193187
* @return string[]

0 commit comments

Comments
 (0)