From 539fdaea1efa7fa35b321031554af8703d00737c Mon Sep 17 00:00:00 2001
From: Tobia De Koninck <tobia@ledfan.be>
Date: Sat, 22 Jul 2017 13:32:56 +0200
Subject: [PATCH] Run repair steps on uninstall in all cases

Signed-off-by: Tobia De Koninck <tobia@ledfan.be>
---
 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 4bf15c23fab..f46ec2a584e 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 16e57d43ebc..eba29d27cf8 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 a2f9fa42693..1d9cb984e2a 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();
-- 
GitLab