diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-06-04 16:40:53 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-06-04 17:16:44 +0200 |
commit | 5b97369b00afbdf55eed145be9ac981dca06d2a9 (patch) | |
tree | 7dbbacea3c7a7253bc37a81d4d9636d320769cd5 /lib/private/app.php | |
parent | 5adb8f0a8a94b955fd031f8d8226e0cbffbfabb1 (diff) | |
download | nextcloud-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/app.php')
-rw-r--r-- | lib/private/app.php | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index 52f77535a52..2650ad98bc6 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -875,6 +875,18 @@ class OC_App { } } + public static function shouldUpgrade($app) { + $versions = self::getAppVersions(); + $currentVersion = OC_App::getAppVersion($app); + if ($currentVersion) { + $installedVersion = $versions[$app]; + if (version_compare($currentVersion, $installedVersion, '>')) { + return true; + } + } + return false; + } + /** * check if the app needs updating and update when needed * @@ -885,26 +897,27 @@ class OC_App { return; } self::$checkedApps[] = $app; + if (!self::shouldUpgrade($app)) { + return; + } $versions = self::getAppVersions(); + $installedVersion = $versions[$app]; $currentVersion = OC_App::getAppVersion($app); - if ($currentVersion) { - $installedVersion = $versions[$app]; - if (version_compare($currentVersion, $installedVersion, '>')) { - $info = self::getAppInfo($app); - OC_Log::write($app, - 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, - OC_Log::DEBUG); - try { - OC_App::updateApp($app); - OC_Hook::emit('update', 'success', 'Updated ' . $info['name'] . ' app'); - } catch (Exception $e) { - OC_Hook::emit('update', 'failure', 'Failed to update ' . $info['name'] . ' app: ' . $e->getMessage()); - $l = OC_L10N::get('lib'); - throw new RuntimeException($l->t('Failed to upgrade "%s".', array($app)), 0, $e); - } - OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app)); - } + OC_Log::write( + $app, + 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, + OC_Log::DEBUG + ); + $info = self::getAppInfo($app); + try { + OC_App::updateApp($app); + OC_Hook::emit('update', 'success', 'Updated ' . $info['name'] . ' app'); + } catch (Exception $e) { + OC_Hook::emit('update', 'failure', 'Failed to update ' . $info['name'] . ' app: ' . $e->getMessage()); + $l = OC_L10N::get('lib'); + throw new RuntimeException($l->t('Failed to upgrade "%s".', array($app)), 0, $e); } + OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app)); } /** |