From 539fdaea1efa7fa35b321031554af8703d00737c Mon Sep 17 00:00:00 2001 From: Tobia De Koninck Date: Sat, 22 Jul 2017 13:32:56 +0200 Subject: [PATCH 1/4] Run repair steps on uninstall in all cases Signed-off-by: Tobia De Koninck --- lib/private/App/AppManager.php | 10 ++++++++++ lib/private/legacy/app.php | 10 ---------- settings/ajax/disableapp.php | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 4bf15c23fa..f46ec2a584 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -287,6 +287,16 @@ class AppManager implements IAppManager { } unset($this->installedAppsCache[$appId]); $this->appConfig->setValue($appId, 'enabled', 'no'); + + // run uninstall steps + $appData = $this->getAppInfo($appId); + if (!is_null($appData)) { + \OC_App::executeRepairSteps($appId, $appData['repair-steps']['uninstall']); + } + + // emit disable hook - needed anymore ? + \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $appId)); + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( ManagerEvent::EVENT_APP_DISABLE, $appId )); diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 16e57d43eb..eba29d27cf 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -431,16 +431,6 @@ class OC_App { // flush self::$enabledAppsCache = []; - // run uninstall steps - $appData = OC_App::getAppInfo($app); - if (!is_null($appData)) { - OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']); - } - - // emit disable hook - needed anymore ? - \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); - - // finally disable it $appManager = \OC::$server->getAppManager(); $appManager->disableApp($app); } diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php index a2f9fa4269..1d9cb984e2 100644 --- a/settings/ajax/disableapp.php +++ b/settings/ajax/disableapp.php @@ -39,6 +39,6 @@ if (!array_key_exists('appid', $_POST)) { $appIds = (array)$_POST['appid']; foreach($appIds as $appId) { $appId = OC_App::cleanAppId($appId); - OC_App::disable($appId); + \OC::$server->getAppManager()->disableApp($appId); } OC_JSON::success(); From 55b9a5d88689f41fa6ae7f7858bc800a495f4b74 Mon Sep 17 00:00:00 2001 From: Tobia De Koninck Date: Tue, 13 Feb 2018 08:03:06 +0100 Subject: [PATCH 2/4] Remove OC_App::disable method Signed-off-by: Tobia De Koninck --- apps/files_sharing/tests/UpdaterTest.php | 2 +- apps/files_trashbin/tests/TrashbinTest.php | 2 +- lib/base.php | 2 +- lib/private/Updater.php | 2 +- lib/private/legacy/app.php | 16 +--------------- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php index c8d089f54b..2e044716d0 100644 --- a/apps/files_sharing/tests/UpdaterTest.php +++ b/apps/files_sharing/tests/UpdaterTest.php @@ -127,7 +127,7 @@ class UpdaterTest extends TestCase { $rootView->deleteAll('files_trashin'); if ($status === false) { - \OC_App::disable('files_trashbin'); + \OC::$server->getAppManager()->disableApp('files_trashbin'); } \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin'); diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 7e4cdb112e..1121940c84 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -71,7 +71,7 @@ class TrashbinTest extends \Test\TestCase { $application->registerMountProviders(); //disable encryption - \OC_App::disable('encryption'); + \OC::$server->getAppManager()->disableApp('encryption'); $config = \OC::$server->getConfig(); //configure trashbin diff --git a/lib/base.php b/lib/base.php index c5eabe1910..f0e139d92c 100644 --- a/lib/base.php +++ b/lib/base.php @@ -949,7 +949,7 @@ class OC { $appIds = (array)$request->getParam('appid'); foreach($appIds as $appId) { $appId = \OC_App::cleanAppId($appId); - \OC_App::disable($appId); + \OC::$server->getAppManager()->disableApp($appId); } \OC_JSON::success(); exit(); diff --git a/lib/private/Updater.php b/lib/private/Updater.php index c70113e1c7..4dc8edc027 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -395,7 +395,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_App::disable($app); + \OC::$server->getAppManager()->disableApp($app); $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 eba29d27cf..303afa797d 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -154,7 +154,7 @@ class OC_App { \OC::$server->getLogger()->logException($ex); if (!\OC::$server->getAppManager()->isShipped($app)) { // Only disable apps which are not shipped - self::disable($app); + \OC::$server->getAppManager()->disableApp($app); } } if (self::isType($app, array('authentication'))) { @@ -421,20 +421,6 @@ class OC_App { } } - /** - * This function set an app as disabled in appconfig. - * - * @param string $app app - * @throws Exception - */ - public static function disable(string $app) { - // flush - self::$enabledAppsCache = []; - - $appManager = \OC::$server->getAppManager(); - $appManager->disableApp($app); - } - /** * Get the path where to install apps * From 96a5752340bc115ad8dffa50cfe3846557f82cc5 Mon Sep 17 00:00:00 2001 From: Tobia De Koninck Date: Tue, 13 Feb 2018 08:04:26 +0100 Subject: [PATCH 3/4] Remove unused $enableAppsCache in OC_App Signed-off-by: Tobia De Koninck --- lib/private/legacy/app.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 303afa797d..bc450ffa25 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -157,13 +157,6 @@ class OC_App { \OC::$server->getAppManager()->disableApp($app); } } - if (self::isType($app, array('authentication'))) { - // since authentication apps affect the "is app enabled for group" check, - // the enabled apps cache needs to be cleared to make sure that the - // next time getEnableApps() is called it will also include apps that were - // enabled for groups - self::$enabledAppsCache = []; - } \OC::$server->getEventLogger()->end('load_app_' . $app); } @@ -329,11 +322,6 @@ class OC_App { } } - /** - * get all enabled apps - */ - protected static $enabledAppsCache = []; - /** * Returns apps enabled for the current user. * @@ -393,7 +381,6 @@ class OC_App { */ public function enable(string $appId, array $groups = []) { - self::$enabledAppsCache = []; // flush // Check if app is already downloaded $installer = \OC::$server->query(Installer::class); From b2a9ea08a3f27eb5f218dd54cd1d1c58582e4f3e Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 6 Mar 2018 17:56:44 +0100 Subject: [PATCH 4/4] Remove unused and outdated hook Signed-off-by: Morris Jobke --- lib/private/App/AppManager.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index f46ec2a584..81f1369cb5 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -294,9 +294,6 @@ class AppManager implements IAppManager { \OC_App::executeRepairSteps($appId, $appData['repair-steps']['uninstall']); } - // emit disable hook - needed anymore ? - \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $appId)); - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( ManagerEvent::EVENT_APP_DISABLE, $appId ));