Skip to content

Commit f417c2e

Browse files
committed
Keep group restrictions when reenabling apps after an update
Signed-off-by: Joas Schilling <[email protected]>
1 parent 164d118 commit f417c2e

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

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\IConfig;
4951
use OCP\ILogger;
5052
use OCP\Util;
@@ -264,9 +266,12 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo
264266
// Update the appfetchers version so it downloads the correct list from the appstore
265267
\OC::$server->getAppFetcher()->setVersion($currentVersion);
266268

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

272277
// install new shipped apps on upgrade
@@ -414,7 +419,7 @@ private function isCodeUpgrade(): bool {
414419
* @throws \Exception
415420
*/
416421
private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false): void {
417-
foreach ($disabledApps as $app) {
422+
foreach ($disabledApps as $app => $previousEnableSetting) {
418423
try {
419424
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
420425
if ($this->installer->isUpdateAvailable($app)) {
@@ -425,7 +430,11 @@ private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false
425430

426431
if ($reenable) {
427432
$ocApp = new \OC_App();
428-
$ocApp->enable($app);
433+
if (!empty($previousEnableSetting)) {
434+
$ocApp->enable($app, $previousEnableSetting);
435+
} else {
436+
$ocApp->enable($app);
437+
}
429438
}
430439
} catch (\Exception $ex) {
431440
$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)