summaryrefslogtreecommitdiffstats
path: root/lib/private/updater.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-06-04 16:40:53 +0200
committerVincent Petry <pvince81@owncloud.com>2014-06-04 17:16:44 +0200
commit5b97369b00afbdf55eed145be9ac981dca06d2a9 (patch)
tree7dbbacea3c7a7253bc37a81d4d9636d320769cd5 /lib/private/updater.php
parent5adb8f0a8a94b955fd031f8d8226e0cbffbfabb1 (diff)
downloadnextcloud-server-5b97369b00afbdf55eed145be9ac981dca06d2a9.tar.gz
nextcloud-server-5b97369b00afbdf55eed145be9ac981dca06d2a9.zip
Simulate apps database schema update on upgrade
When upgrade, also simulate the database schema update for apps before doing the actual upgrade.
Diffstat (limited to 'lib/private/updater.php')
-rw-r--r--lib/private/updater.php62
1 files changed, 48 insertions, 14 deletions
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 58d3cab73aa..1c363123e10 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -125,29 +125,63 @@ class Updater extends BasicEmitter {
* STOP CONFIG CHANGES FOR OLDER VERSIONS
*/
+ $canUpgrade = false;
+ // simulate DB upgrade
try {
- \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
- $this->emit('\OC\Updater', 'dbUpgrade');
-
+ // simulate core DB upgrade
+ \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml', true);
+
+ // simulate apps DB upgrade
+ $version = \OC_Util::getVersion();
+ $apps = \OC_App::getEnabledApps();
+ foreach ($apps as $appId) {
+ $info = \OC_App::getAppInfo($appId);
+ if (\OC_App::isAppCompatible($version, $info) && \OC_App::shouldUpgrade($appId)) {
+ if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
+ \OC_DB::updateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml', true);
+ }
+ }
+ }
+
+ $this->emit('\OC\Updater', 'dbSimulateUpgrade');
+
+ $canUpgrade = true;
} catch (\Exception $exception) {
$this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
}
- \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
- $disabledApps = \OC_App::checkAppsRequirements();
- if (!empty($disabledApps)) {
- $this->emit('\OC\Updater', 'disabledApps', array($disabledApps));
- }
- // load all apps to also upgrade enabled apps
- \OC_App::loadApps();
- $repair = new Repair();
- $repair->run();
+ if ($canUpgrade) {
+ // proceed with real upgrade
+ try {
+ // do the real upgrade
+ \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
+ $this->emit('\OC\Updater', 'dbUpgrade');
+
+ } catch (\Exception $exception) {
+ $this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
+ return false;
+ }
+ // TODO: why not do this at the end ?
+ \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
+ $disabledApps = \OC_App::checkAppsRequirements();
+ if (!empty($disabledApps)) {
+ $this->emit('\OC\Updater', 'disabledApps', array($disabledApps));
+ }
+ // load all apps to also upgrade enabled apps
+ \OC_App::loadApps();
+
+ $repair = new Repair();
+ $repair->run();
+
+ //Invalidate update feed
+ \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
+ }
- //Invalidate update feed
- \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
\OC_Config::setValue('maintenance', false);
$this->emit('\OC\Updater', 'maintenanceEnd');
+
+ return $canUpgrade;
}
}