summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-06-14 02:13:18 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-06-14 02:13:18 -0700
commit27f7ef49e49285ee8a2a0a078fdbe625815fc848 (patch)
tree6e2dbb4b45171ed14836bd73d5c1aeae67d8a3e4
parenta8a60d761b12d59923e70da06f0b84954c2e3ec7 (diff)
parentc8564c07955ead3e85daa67e1871a2c41df3a6d5 (diff)
downloadnextcloud-server-27f7ef49e49285ee8a2a0a078fdbe625815fc848.tar.gz
nextcloud-server-27f7ef49e49285ee8a2a0a078fdbe625815fc848.zip
Merge pull request #2835 from owncloud/move-maint-start
Move maintenance start to ajax call
-rw-r--r--core/ajax/update.php9
-rw-r--r--lib/base.php5
-rw-r--r--lib/config.php2
-rw-r--r--lib/connector/sabre/maintenanceplugin.php3
-rwxr-xr-xlib/util.php20
5 files changed, 32 insertions, 7 deletions
diff --git a/core/ajax/update.php b/core/ajax/update.php
index 6015a901eb7..db00da02239 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -5,11 +5,15 @@ require_once '../../lib/base.php';
if (OC::checkUpgrade(false)) {
\OC_DB::enableCaching(false);
+ OC_Config::setValue('maintenance', true);
+ $installedVersion = OC_Config::getValue('version', '0.0.0');
+ $currentVersion = implode('.', OC_Util::getVersion());
+ OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::WARN);
$updateEventSource = new OC_EventSource();
$watcher = new UpdateWatcher($updateEventSource);
OC_Hook::connect('update', 'success', $watcher, 'success');
OC_Hook::connect('update', 'error', $watcher, 'error');
- OC_Hook::connect('update', 'error', $watcher, 'failure');
+ OC_Hook::connect('update', 'failure', $watcher, 'failure');
$watcher->success('Turned on maintenance mode');
try {
$result = OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml');
@@ -99,6 +103,7 @@ class UpdateWatcher {
OC_Util::obEnd();
$this->eventSource->send('failure', $message);
$this->eventSource->close();
+ OC_Config::setValue('maintenance', false);
die();
}
@@ -108,4 +113,4 @@ class UpdateWatcher {
$this->eventSource->close();
}
-}
+} \ No newline at end of file
diff --git a/lib/base.php b/lib/base.php
index a6e4a47dbf5..26e9595e869 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -235,10 +235,7 @@ class OC {
$currentVersion = implode('.', OC_Util::getVersion());
if (version_compare($currentVersion, $installedVersion, '>')) {
if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
- OC_Config::setValue('maintenance', true);
- OC_Log::write('core',
- 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion,
- OC_Log::WARN);
+ OC_Config::setValue('theme', '');
$minimizerCSS = new OC_Minimizer_CSS();
$minimizerCSS->clearCache();
$minimizerJS = new OC_Minimizer_JS();
diff --git a/lib/config.php b/lib/config.php
index 9b87d4ce4e5..3cbb89fb981 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -187,7 +187,7 @@ class OC_Config{
}
// Prevent others not to read the config
@chmod($filename, 0640);
-
+ OC_Util::clearOpcodeCache();
return true;
}
}
diff --git a/lib/connector/sabre/maintenanceplugin.php b/lib/connector/sabre/maintenanceplugin.php
index 329fa4443ad..2eda269afc2 100644
--- a/lib/connector/sabre/maintenanceplugin.php
+++ b/lib/connector/sabre/maintenanceplugin.php
@@ -50,6 +50,9 @@ class OC_Connector_Sabre_MaintenancePlugin extends Sabre_DAV_ServerPlugin
if (OC_Config::getValue('maintenance', false)) {
throw new Sabre_DAV_Exception_ServiceUnavailable();
}
+ if (OC::checkUpgrade(false)) {
+ throw new Sabre_DAV_Exception_ServiceUnavailable('Upgrade needed');
+ }
return true;
}
diff --git a/lib/util.php b/lib/util.php
index 95af22ed0ee..ddef0c63c55 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -833,6 +833,26 @@ class OC_Util {
}
/**
+ * Clear the opcode cache if one exists
+ * This is necessary for writing to the config file
+ * in case the opcode cache doesn't revalidate files
+ */
+ public static function clearOpcodeCache() {
+ // APC
+ if (function_exists('apc_clear_cache')) {
+ apc_clear_cache();
+ }
+ // Zend Opcache
+ if (function_exists('accelerator_reset')) {
+ accelerator_reset();
+ }
+ // XCache
+ if (function_exists('xcache_clear_cache')) {
+ xcache_clear_cache(XC_TYPE_VAR, 0);
+ }
+ }
+
+ /**
* Normalize a unicode string
* @param string $value a not normalized string
* @return bool|string