From 2dfe749fce7c817aaa0a9ebd30bf5282a372d84c Mon Sep 17 00:00:00 2001 From: BeezyT <timo@ezdesign.de> Date: Thu, 16 Aug 2012 13:59:26 +0000 Subject: [PATCH] refs #2976 updates can be marked a major git-svn-id: http://dev.piwik.org/svn/trunk@6790 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- core/Updater.php | 27 +++++++++++ core/Updates.php | 47 +++++++++++++++++++ lang/en.php | 2 + plugins/CoreUpdater/Controller.php | 1 + .../CoreUpdater/templates/update_welcome.tpl | 6 +++ themes/default/simple_structure.css | 4 ++ 6 files changed, 87 insertions(+) diff --git a/core/Updater.php b/core/Updater.php index ae3821d080..b993c9b46a 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -97,6 +97,33 @@ class Piwik_Updater isset($this->componentsWithNewVersion[$componentName]); } + /** + * Does one of the new versions involve a major database update? + * + * @return bool + */ + public function hasMajorDbUpdate() + { + foreach($this->componentsWithUpdateFile as $componentName => $componentUpdateInfo) + { + foreach($componentUpdateInfo as $file => $fileVersion) + { + require_once $file; + + $className = $this->getUpdateClassName($componentName, $fileVersion); + if(class_exists($className, false)) + { + $isMajor = call_user_func( array($className, 'isMajorUpdate')); + if ($isMajor) { + return true; + } + } + } + } + + return false; + } + /** * Returns the list of SQL queries that would be executed during the update * diff --git a/core/Updates.php b/core/Updates.php index f932227ad9..e53a1d5bbc 100644 --- a/core/Updates.php +++ b/core/Updates.php @@ -39,4 +39,51 @@ abstract class Piwik_Updates static function update() { } + + /** + * Tell the updater that this is a major update. + * Leads to a more visible notice. + */ + static function isMajorUpdate() + { + return false; + } + + /** + * Helper method to enable maintenance mode during large updates + */ + static function enableMaintenanceMode() + { + $config = Piwik_Config::getInstance(); + $config->init(); + + $tracker = $config->Tracker; + $tracker['record_statistics'] = 0; + $config->Tracker = $tracker; + + $general = $config->General; + $general['maintenance_mode'] = 1; + $config->General = $general; + + $config->forceSave(); + } + + /** + * Helper method to disable maintenance mode after large updates + */ + static function disableMaintenanceMode() + { + $config = Piwik_Config::getInstance(); + $config->init(); + + $tracker = $config->Tracker; + $tracker['record_statistics'] = 1; + $config->Tracker = $tracker; + + $general = $config->General; + $general['maintenance_mode'] = 0; + $config->General = $general; + + $config->forceSave(); + } } diff --git a/lang/en.php b/lang/en.php index f51c77a8f5..c1679a0872 100644 --- a/lang/en.php +++ b/lang/en.php @@ -602,6 +602,8 @@ $translations = array( 'CoreUpdater_ExceptionArchiveIncompatible' => 'Incompatible archive: %s', 'CoreUpdater_ExceptionArchiveEmpty' => 'Empty archive.', 'CoreUpdater_ExceptionArchiveIncomplete' => 'Archive is incomplete: some files are missing (eg. %s).', + 'CoreUpdater_MajorUpdateWarning1' => 'This is a major update! It will take longer than usual.', + 'CoreUpdater_MajorUpdateWarning2' => 'The following advice is especially important for large installations.', 'CustomVariables_PluginDescription' => 'Custom Variables are name,value pairs that you can set to a Visit using the Javascript API setVisitCustomVariables() function. Piwik will then report how many visits, pages, conversions for each of these custom names and values.', 'CustomVariables_CustomVariables' => 'Custom Variables', 'CustomVariables_ColumnCustomVariableName' => 'Custom Variable name', diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index a8ade9afc1..567198bcca 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -280,6 +280,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller { $view = Piwik_View::factory('update_welcome'); $view->queries = $sqlQueries; + $view->isMajor = $updater->hasMajorDbUpdate(); $this->doWelcomeUpdates($view, $componentsWithUpdateFile); echo $view->render(); } diff --git a/plugins/CoreUpdater/templates/update_welcome.tpl b/plugins/CoreUpdater/templates/update_welcome.tpl index f6c1b712e9..434b8ad99c 100644 --- a/plugins/CoreUpdater/templates/update_welcome.tpl +++ b/plugins/CoreUpdater/templates/update_welcome.tpl @@ -28,6 +28,12 @@ {/if} <h3 id='titleUpdate'>{'CoreUpdater_NoteForLargePiwikInstances'|translate}</h3> + {if $isMajor} + <p class="warning normalFontSize"> + {'CoreUpdater_MajorUpdateWarning1'|translate}<br /> + {'CoreUpdater_MajorUpdateWarning2'|translate} + </p> + {/if} <ul> <li>{'CoreUpdater_TheUpgradeProcessMayFailExecuteCommand'|translate:$commandUpgradePiwik}</li> <li>It is also recommended for high traffic Piwik servers to <a target='_blank' href='?module=Proxy&action=redirect&url={"http://piwik.org/faq/how-to/#faq_111"|escape:"url"}'>momentarily disable visitor Tracking and put the Piwik User Interface in maintenance mode</a>.</li> diff --git a/themes/default/simple_structure.css b/themes/default/simple_structure.css index 1c728665c7..7d0da3c777 100644 --- a/themes/default/simple_structure.css +++ b/themes/default/simple_structure.css @@ -93,3 +93,7 @@ a { color: #006; } -webkit-border-radius:4px; padding:15px; } +.warning.normalFontSize { + font-size: 100%; + padding: 10px; +} \ No newline at end of file -- GitLab