diff options
Diffstat (limited to 'lib/private/app.php')
-rw-r--r-- | lib/private/app.php | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index cf0ccbb2272..7bcbef32531 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -47,6 +47,7 @@ use OC\App\DependencyAnalyzer; use OC\App\Platform; use OC\OCSClient; +use OC\Repair; /** * This class manages the apps. It allows them to register and integrate in the @@ -1031,7 +1032,6 @@ class OC_App { if (!empty($requireMax) && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>') ) { - return false; } @@ -1051,7 +1051,6 @@ class OC_App { return $versions; } - /** * @param string $app * @return bool @@ -1148,9 +1147,12 @@ class OC_App { if($appPath === false) { return false; } + $appData = self::getAppInfo($appId); + self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); if (file_exists($appPath . '/appinfo/database.xml')) { OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); } + self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); unset(self::$appVersion[$appId]); // run upgrade code if (file_exists($appPath . '/appinfo/update.php')) { @@ -1159,7 +1161,6 @@ class OC_App { } //set remote/public handlers - $appData = self::getAppInfo($appId); if (array_key_exists('ocsid', $appData)) { \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { @@ -1182,6 +1183,34 @@ class OC_App { /** * @param string $appId + * @param string[] $steps + * @throws \OC\NeedsUpdateException + */ + private static function executeRepairSteps($appId, array $steps) { + if (empty($steps)) { + return; + } + // load the app + self::loadApp($appId, false); + + $dispatcher = OC::$server->getEventDispatcher(); + + // load the steps + $r = new Repair([], $dispatcher); + foreach ($steps as $step) { + try { + $r->addStep($step); + } catch (Exception $ex) { + $r->emit('\OC\Repair', 'error', [$ex->getMessage()]); + \OC::$server->getLogger()->logException($ex); + } + } + // run the steps + $r->run(); + } + + /** + * @param string $appId * @return \OC\Files\View|false */ public static function getStorage($appId) { |