Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class AppManager implements IAppManager {
/** @var array */
private $appVersions = [];

/** @var array */
private $autoDisabledApps = [];

/**
* @param IUserSession $userSession
* @param AppConfig $appConfig
Expand Down Expand Up @@ -148,6 +151,13 @@ public function getEnabledAppsForUser(IUser $user) {
return array_keys($appsForUser);
}

/**
* @return array
*/
public function getAutoDisabledApps(): array {
return $this->autoDisabledApps;
}

/**
* Check if an app is enabled for user
*
Expand Down Expand Up @@ -282,12 +292,18 @@ public function enableAppForGroups($appId, $groups) {
* 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');

Expand Down
5 changes: 3 additions & 2 deletions lib/private/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ private function doUpgrade($currentVersion, $installedVersion) {

// upgrade appstore apps
$this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
$this->upgradeAppStoreApps(\OC_App::$autoDisabledApps, true);
$autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps();
$this->upgradeAppStoreApps($autoDisabledApps, true);

// install new shipped apps on upgrade
OC_App::loadApps(['authentication']);
Expand Down Expand Up @@ -404,7 +405,7 @@ private function checkAppsRequirements() {
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);
\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
Expand Down
4 changes: 1 addition & 3 deletions lib/private/legacy/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -157,8 +156,7 @@ public static function loadApp(string $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);
Expand Down
9 changes: 8 additions & 1 deletion lib/public/App/IAppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ public function enableAppForGroups($appId, $groups);
* 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.
Expand Down Expand Up @@ -158,4 +159,10 @@ public function isShipped($appId);
* @since 9.0.0
*/
public function getAlwaysEnabledApps();

/**
* @return array
* @since 16.0.5
*/
public function getAutoDisabledApps(): array;
}