From f6c34240395bd53e160bdc8bac10e504451553b8 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 22 Jul 2019 21:28:03 +0200 Subject: [PATCH 1/2] Fix tracking of auto disabled apps in Updater Signed-off-by: Georg Ehrke --- lib/private/Updater.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 56bea90ddd..87e68b84cf 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -74,6 +74,13 @@ class Updater extends BasicEmitter { 4 => 'Fatal', ]; + /** + * List of appIds that have automatically been disabled during upgrade + * + * @var String[] + */ + private $autoDisabledApps = []; + /** * @param IConfig $config * @param Checker $checker @@ -256,7 +263,8 @@ class Updater extends BasicEmitter { // upgrade appstore apps $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps()); - $this->upgradeAppStoreApps(\OC_App::$autoDisabledApps, true); + $autoDisabledApps = array_merge(\OC_App::$autoDisabledApps, $this->autoDisabledApps); + $this->upgradeAppStoreApps($autoDisabledApps, true); // install new shipped apps on upgrade OC_App::loadApps(['authentication']); @@ -405,6 +413,7 @@ class Updater extends BasicEmitter { throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); } \OC::$server->getAppManager()->disableApp($app); + $this->autoDisabledApps[] = $app; $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app)); } // no need to disable any app in case this is a non-core upgrade From 810ee7d811c4cf0291add770cb89e5b6d11104b9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Jul 2019 10:28:47 +0200 Subject: [PATCH 2/2] Make the auto-disabled list more broad Signed-off-by: Joas Schilling --- lib/private/App/AppManager.php | 18 +++++++++++++++++- lib/private/Updater.php | 12 ++---------- lib/private/legacy/app.php | 4 +--- lib/public/App/IAppManager.php | 9 ++++++++- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index db286d7ad7..322731d677 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -91,6 +91,9 @@ class AppManager implements IAppManager { /** @var array */ private $appVersions = []; + /** @var array */ + private $autoDisabledApps = []; + /** * @param IUserSession $userSession * @param AppConfig $appConfig @@ -167,6 +170,13 @@ class AppManager implements IAppManager { return array_keys($appsForGroups); } + /** + * @return array + */ + public function getAutoDisabledApps(): array { + return $this->autoDisabledApps; + } + /** * @param string $appId * @return array @@ -351,12 +361,18 @@ class AppManager implements IAppManager { * Disable an app for every user * * @param string $appId + * @param bool $automaticDisabled * @throws \Exception if app can't be disabled */ - public function disableApp($appId) { + public function disableApp($appId, $automaticDisabled = false) { if ($this->isAlwaysEnabled($appId)) { throw new \Exception("$appId can't be disabled."); } + + if ($automaticDisabled) { + $this->autoDisabledApps[] = $appId; + } + unset($this->installedAppsCache[$appId]); $this->appConfig->setValue($appId, 'enabled', 'no'); diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 87e68b84cf..d5de1bf6b2 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -74,13 +74,6 @@ class Updater extends BasicEmitter { 4 => 'Fatal', ]; - /** - * List of appIds that have automatically been disabled during upgrade - * - * @var String[] - */ - private $autoDisabledApps = []; - /** * @param IConfig $config * @param Checker $checker @@ -263,7 +256,7 @@ class Updater extends BasicEmitter { // upgrade appstore apps $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps()); - $autoDisabledApps = array_merge(\OC_App::$autoDisabledApps, $this->autoDisabledApps); + $autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps(); $this->upgradeAppStoreApps($autoDisabledApps, true); // install new shipped apps on upgrade @@ -412,8 +405,7 @@ class Updater extends BasicEmitter { if ($appManager->isShipped($app)) { throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); } - \OC::$server->getAppManager()->disableApp($app); - $this->autoDisabledApps[] = $app; + \OC::$server->getAppManager()->disableApp($app, true); $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app)); } // no need to disable any app in case this is a non-core upgrade diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index d495bef2eb..58b617aae4 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -70,7 +70,6 @@ class OC_App { static private $loadedApps = []; static private $altLogin = []; static private $alreadyRegistered = []; - static public $autoDisabledApps = []; const supportedApp = 300; const officialApp = 200; @@ -157,8 +156,7 @@ class OC_App { \OC::$server->getLogger()->logException($ex); if (!\OC::$server->getAppManager()->isShipped($app)) { // Only disable apps which are not shipped - \OC::$server->getAppManager()->disableApp($app); - self::$autoDisabledApps[] = $app; + \OC::$server->getAppManager()->disableApp($app, true); } } \OC::$server->getEventLogger()->end('load_app_' . $app); diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 6213227bfd..aebd47b3a2 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -110,9 +110,10 @@ interface IAppManager { * Disable an app for every user * * @param string $appId + * @param bool $automaticDisabled * @since 8.0.0 */ - public function disableApp($appId); + public function disableApp($appId, $automaticDisabled = false); /** * Get the directory for the given app. @@ -167,6 +168,12 @@ interface IAppManager { */ public function getEnabledAppsForGroup(IGroup $group): array; + /** + * @return array + * @since 17.0.0 + */ + public function getAutoDisabledApps(): array; + /** * @param String $appId * @return string[]