diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-12-15 10:25:22 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-12-15 10:25:22 +0300 |
commit | c93d3e84a48cdfe5cf397b2fbd2e215014c5777d (patch) | |
tree | c6315bec3cb1bd47e7dd1c53cc1e3ee1158a6d3d /core | |
parent | 12d4618aebf7d0658e28fef3d50c6ba2d5fb449e (diff) |
Fixes #6529 Throw an exception when codebase is older than schema to prevent broken race conditions
Diffstat (limited to 'core')
-rw-r--r-- | core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php | 14 | ||||
-rw-r--r-- | core/FrontController.php | 2 | ||||
-rw-r--r-- | core/Updater.php | 21 |
3 files changed, 37 insertions, 0 deletions
diff --git a/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php b/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php new file mode 100644 index 0000000000..accc4ce5d5 --- /dev/null +++ b/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php @@ -0,0 +1,14 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Exception; + +class DatabaseSchemaIsNewerThanCodebaseException extends Exception +{ + +}
\ No newline at end of file diff --git a/core/FrontController.php b/core/FrontController.php index 7d1702315f..dbaf75e22c 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -399,6 +399,8 @@ class FrontController extends Singleton */ Piwik::postEvent('Request.dispatchCoreAndPluginUpdatesScreen'); + Updater::throwIfPiwikVersionIsOlderThanDBSchema(); + \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins(); // ensure the current Piwik URL is known for later use diff --git a/core/Updater.php b/core/Updater.php index 692034d5e9..c9872d3481 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -8,6 +8,7 @@ */ namespace Piwik; use Piwik\Columns\Updater as ColumnUpdater; +use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException; /** * Load and execute all relevant, incremental update scripts for Piwik core and plugins, and bump the component version numbers for completed updates. @@ -95,6 +96,26 @@ class Updater return 'version_' . $name; } + + /** + * This method ensures that Piwik Platform cannot be running when using a NEWER database + */ + public static function throwIfPiwikVersionIsOlderThanDBSchema() + { + $dbSchemaVersion = self::getCurrentRecordedComponentVersion('core'); + $current = Version::VERSION; + if(-1 === version_compare($current, $dbSchemaVersion)) { + $messages = array( + Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebase', array($current, $dbSchemaVersion)), + Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebaseWait'), + // we cannot fill in the Super User emails as we are failing before Authentication was ready + Piwik::translate('General_ExceptionContactSupportGeneric', array('', '')) + ); + throw new DatabaseSchemaIsNewerThanCodebaseException(implode(" ", $messages)); + } + } + + /** * Returns a list of components (core | plugin) that need to run through the upgrade process. * |