Keep group restrictions when reenabling apps after an update

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-10-01 16:40:25 +02:00
parent e229cd3d53
commit 7f4b3fb68d
No known key found for this signature in database
GPG key ID: 7076EA9751AACDDA
3 changed files with 18 additions and 11 deletions

View file

@ -400,7 +400,11 @@ class AppManager implements IAppManager {
}
if ($automaticDisabled) {
$this->autoDisabledApps[] = $appId;
$previousSetting = $this->appConfig->getValue($appId, 'enabled', 'yes');
if ($previousSetting !== 'yes' && $previousSetting !== 'no') {
$previousSetting = json_decode($previousSetting, true);
}
$this->autoDisabledApps[$appId] = $previousSetting;
}
unset($this->installedAppsCache[$appId]);

View file

@ -37,11 +37,13 @@
namespace OC;
use OC\App\AppManager;
use OC\DB\Connection;
use OC\DB\MigrationService;
use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker;
use OC_App;
use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Util;
@ -262,9 +264,12 @@ class Updater extends BasicEmitter {
// Update the appfetchers version so it downloads the correct list from the appstore
\OC::$server->getAppFetcher()->setVersion($currentVersion);
/** @var IAppManager|AppManager $appManager */
$appManager = \OC::$server->getAppManager();
// upgrade appstore apps
$this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
$autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps();
$this->upgradeAppStoreApps($appManager->getInstalledApps());
$autoDisabledApps = $appManager->getAutoDisabledApps();
$this->upgradeAppStoreApps($autoDisabledApps, true);
// install new shipped apps on upgrade
@ -409,7 +414,7 @@ class Updater extends BasicEmitter {
* @throws \Exception
*/
private function upgradeAppStoreApps(array $disabledApps, $reenable = false) {
foreach ($disabledApps as $app) {
foreach ($disabledApps as $app => $previousEnableSetting) {
try {
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
if ($this->installer->isUpdateAvailable($app)) {
@ -420,7 +425,11 @@ class Updater extends BasicEmitter {
if ($reenable) {
$ocApp = new \OC_App();
$ocApp->enable($app);
if (!empty($previousEnableSetting)) {
$ocApp->enable($app, $previousEnableSetting);
} else {
$ocApp->enable($app);
}
}
} catch (\Exception $ex) {
$this->log->logException($ex, ['app' => 'core']);

View file

@ -183,12 +183,6 @@ interface IAppManager {
*/
public function getEnabledAppsForGroup(IGroup $group): array;
/**
* @return array
* @since 17.0.0
*/
public function getAutoDisabledApps(): array;
/**
* @param String $appId
* @return string[]