Skip to content

Commit

Permalink
Merge pull request #14040 from owncloud/stable7-app-upgrade-order
Browse files Browse the repository at this point in the history
[Stable7] app upgrade order fix
  • Loading branch information
LukasReschke committed Feb 17, 2015
2 parents 7b432cb + 6185253 commit 4316387
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions lib/private/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,47 @@ private function includePreUpdate($appId) {
include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php';
}


/**
* upgrades all apps within a major ownCloud upgrade. Also loads "priority"
* (types authentication, filesystem, logging, in that order) afterwards.
*
* @throws NeedsUpdateException
*/
protected function doAppUpgrade() {
$apps = \OC_App::getEnabledApps();
$priorityTypes = array('authentication', 'filesystem', 'logging');
$pseudoOtherType = 'other';
$stacks = array($pseudoOtherType => array());

foreach ($apps as $appId) {
if (\OC_App::shouldUpgrade($appId)) {
\OC_App::updateApp($appId);
$this->emit('\OC\Updater', 'appUpgrade', array($appId, \OC_App::getAppVersion($appId)));
$priorityType = false;
foreach ($priorityTypes as $type) {
if(!isset($stacks[$type])) {
$stacks[$type] = array();
}
if (\OC_App::isType($appId, $type)) {
$stacks[$type][] = $appId;
$priorityType = true;
break;
}
}
if (!$priorityType) {
$stacks[$pseudoOtherType][] = $appId;
}
}
foreach ($stacks as $type => $stack) {
foreach ($stack as $appId) {
if (\OC_App::shouldUpgrade($appId)) {
\OC_App::updateApp($appId);
$this->emit('\OC\Updater', 'appUpgrade', array($appId, \OC_App::getAppVersion($appId)));
}
if($type !== $pseudoOtherType) {
// load authentication, filesystem and logging apps after
// upgrading them. Other apps my need to rely on modifying
// user and/or filesystem aspects.
\OC_App::loadApp($appId, false);
}
}
}
}
Expand Down

0 comments on commit 4316387

Please sign in to comment.