diff --git a/core/Updater.php b/core/Updater.php index ae3821d0803a2f986393981ddc7d37737ad93010..b993c9b46a864bf8a2fde0eb9963674c59aa407b 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 f932227ad90d84b535c6032df85d95b4fbc60f3f..e53a1d5bbc97f901d3b7fe0783d9c52e1d0dfae0 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 f51c77a8f5ee07305539b7a4f496a11c5c644694..c1679a0872b0b7341fe9fa14976a97801cc07d5f 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 a8ade9afc14fe0f49b4528ae7b79a117952789de..567198bcca0f6b58d11d1ef0c716cb4fbe39494c 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 f6c1b712e9297e636a24665649ba436aced3f955..434b8ad99c3cd4db1e590d1dcb1746f9e2127cc6 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 1c728665c7f61237f36965234d72078a90678385..7d0da3c777528d70a074bad77c9ab8bf58414aaf 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