From 41f7eb948ad09632764cd8503dcec6c5fa6093cd Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 9 Apr 2013 20:51:43 +0200 Subject: [PATCH 1/6] Move start of the maintenance mode to the ajax call Make sure the update page is shown in a browser. And not an ajax request --- core/ajax/update.php | 3 +++ lib/base.php | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/ajax/update.php b/core/ajax/update.php index 6015a901eb..9d0c6f89f1 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -5,6 +5,8 @@ require_once '../../lib/base.php'; if (OC::checkUpgrade(false)) { \OC_DB::enableCaching(false); + OC_Config::setValue('maintenance', true); + 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'); @@ -99,6 +101,7 @@ class UpdateWatcher { OC_Util::obEnd(); $this->eventSource->send('failure', $message); $this->eventSource->close(); + OC_Config::setValue('maintenance', false); die(); } diff --git a/lib/base.php b/lib/base.php index 8633ae9b63..1e4bbff49c 100644 --- a/lib/base.php +++ b/lib/base.php @@ -282,10 +282,6 @@ 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); $minimizerCSS = new OC_Minimizer_CSS(); $minimizerCSS->clearCache(); $minimizerJS = new OC_Minimizer_JS(); From ff64c87adbadd1791f08a53277eafdb2d58079d5 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 9 Apr 2013 21:05:11 +0200 Subject: [PATCH 2/6] Connect watcher failure function to the failure signal --- core/ajax/update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ajax/update.php b/core/ajax/update.php index 9d0c6f89f1..af469237a1 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -11,7 +11,7 @@ if (OC::checkUpgrade(false)) { $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'); From 460f827f7e5d80cfa56b70536e86ac0aea0cd448 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 16 Apr 2013 08:07:44 +0200 Subject: [PATCH 3/6] Also check for needed upgrade in the Sabre Maintenance connector --- lib/connector/sabre/maintenanceplugin.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/connector/sabre/maintenanceplugin.php b/lib/connector/sabre/maintenanceplugin.php index 329fa4443a..2eda269afc 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; } From f8336c1e2c17414649eceb0f2351524629c15899 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Tue, 14 May 2013 09:34:01 -0400 Subject: [PATCH 4/6] Turn off theme before update --- lib/base.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/base.php b/lib/base.php index 1e4bbff49c..e4f2d98e5e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -282,6 +282,7 @@ class OC { $currentVersion = implode('.', OC_Util::getVersion()); if (version_compare($currentVersion, $installedVersion, '>')) { if ($showTemplate && !OC_Config::getValue('maintenance', false)) { + OC_Config::setValue('theme', ''); $minimizerCSS = new OC_Minimizer_CSS(); $minimizerCSS->clearCache(); $minimizerJS = new OC_Minimizer_JS(); From 4687f50e754f54349ea33348a45cacddaa10261a Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Fri, 17 May 2013 11:15:53 -0400 Subject: [PATCH 5/6] Add undefined verision variables --- core/ajax/update.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/ajax/update.php b/core/ajax/update.php index af469237a1..db00da0223 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -6,6 +6,8 @@ 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); @@ -111,4 +113,4 @@ class UpdateWatcher { $this->eventSource->close(); } -} +} \ No newline at end of file From 0a29d2029a719d42f347edb95bd6486c2ab842a8 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 25 May 2013 11:25:43 -0400 Subject: [PATCH 6/6] Clear opcode caches after writing to the config file, fixes #3372 --- lib/config.php | 2 +- lib/util.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/config.php b/lib/config.php index 9b87d4ce4e..3cbb89fb98 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/util.php b/lib/util.php index f30cdf6a53..a7ed037929 100755 --- a/lib/util.php +++ b/lib/util.php @@ -822,5 +822,24 @@ class OC_Util { return $theme; } + /** + * 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); + } + } }