From f5b1f598ea5da3b8ed0d265a7f59936e776ceb6c Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 14 Jun 2013 13:34:01 +0200 Subject: [PATCH] Squashed commit of the following: commit 85043af59846edd54b6f402829a698142fdb412f Author: Michael Gapczynski Date: Sat May 25 11:25:43 2013 -0400 Clear opcode caches after writing to the config file, fixes #3372 commit e96ca0a217112a612e5018fb06115879be634f0b Author: Michael Gapczynski Date: Fri May 17 11:15:53 2013 -0400 Add undefined verision variables commit d7faeea0b8a79bcd84255120e396280fe62c8aa1 Author: Michael Gapczynski Date: Tue May 14 09:34:01 2013 -0400 Turn off theme before update commit f620df4e88201a8d35ecb6173f258d5e5f67c7f9 Author: Bart Visscher Date: Tue Apr 16 08:07:44 2013 +0200 Also check for needed upgrade in the Sabre Maintenance connector commit 223cfce8c89663beb95cf7438f47cea4bac6e0de Author: Bart Visscher Date: Tue Apr 9 21:05:11 2013 +0200 Connect watcher failure function to the failure signal commit 49b9a1e8af062c03ebc863e1139ca310944b784a Author: Bart Visscher Date: Tue Apr 9 20:51:43 2013 +0200 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 | 7 ++++++- lib/base.php | 5 +---- lib/config.php | 2 +- lib/connector/sabre/maintenanceplugin.php | 3 +++ lib/util.php | 19 +++++++++++++++++++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/core/ajax/update.php b/core/ajax/update.php index d5588b7c852..0b1c9386282 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(); } diff --git a/lib/base.php b/lib/base.php index 6bdabc011f2..b58ffb4dfbb 100644 --- a/lib/base.php +++ b/lib/base.php @@ -275,10 +275,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 0bd497b8e50..4f216a2dfc3 100644 --- a/lib/config.php +++ b/lib/config.php @@ -173,7 +173,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 7f5f30aa619..9d2038a26b1 100755 --- a/lib/util.php +++ b/lib/util.php @@ -825,5 +825,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); + } + } } -- 2.39.5