summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-11-13 12:07:10 +0100
committerLukas Reschke <lukas@owncloud.com>2014-11-13 12:07:10 +0100
commit2b3b4272f89fe87389d9217c48b177d1bab3a450 (patch)
treeb5353c95a185a0cc4021a762edc9d05c721bc66d /lib/private
parent1e5a39ea6c4dfcd5f33fab1c7dd163d9c3a5c007 (diff)
parent778efcb054c2669f12528d2c1a3e8939ba7e762f (diff)
downloadnextcloud-server-2b3b4272f89fe87389d9217c48b177d1bab3a450.tar.gz
nextcloud-server-2b3b4272f89fe87389d9217c48b177d1bab3a450.zip
Merge pull request #12109 from owncloud/add-preupdate-before-upgrade
Run preupdate before an update
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/app.php4
-rw-r--r--lib/private/updater.php18
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index 20c0f5f50ae..971277595e9 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -1186,10 +1186,6 @@ class OC_App {
* @return bool
*/
public static function updateApp($appId) {
- if (file_exists(self::getAppPath($appId) . '/appinfo/preupdate.php')) {
- self::loadApp($appId, false);
- include self::getAppPath($appId) . '/appinfo/preupdate.php';
- }
if (file_exists(self::getAppPath($appId) . '/appinfo/database.xml')) {
OC_DB::updateDbFromStructure(self::getAppPath($appId) . '/appinfo/database.xml');
}
diff --git a/lib/private/updater.php b/lib/private/updater.php
index a2aa8bf33e9..7d271c4480c 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -262,7 +262,6 @@ class Updater extends BasicEmitter {
protected function checkAppUpgrade($version) {
$apps = \OC_App::getEnabledApps();
-
foreach ($apps as $appId) {
if ($version) {
$info = \OC_App::getAppInfo($appId);
@@ -272,6 +271,15 @@ class Updater extends BasicEmitter {
}
if ($compatible && \OC_App::shouldUpgrade($appId)) {
+ /**
+ * FIXME: The preupdate check is performed before the database migration, otherwise database changes
+ * are not possible anymore within it. - Consider this when touching the code.
+ * @link https://github.com/owncloud/core/issues/10980
+ * @see \OC_App::updateApp
+ */
+ if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
+ $this->includePreUpdate($appId);
+ }
if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
\OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
}
@@ -281,6 +289,14 @@ class Updater extends BasicEmitter {
$this->emit('\OC\Updater', 'appUpgradeCheck');
}
+ /**
+ * Includes the pre-update file. Done here to prevent namespace mixups.
+ * @param string $appId
+ */
+ private function includePreUpdate($appId) {
+ include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php';
+ }
+
protected function doAppUpgrade() {
$apps = \OC_App::getEnabledApps();