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/Updater.php | |
parent | 12d4618aebf7d0658e28fef3d50c6ba2d5fb449e (diff) |
Fixes #6529 Throw an exception when codebase is older than schema to prevent broken race conditions
Diffstat (limited to 'core/Updater.php')
-rw-r--r-- | core/Updater.php | 21 |
1 files changed, 21 insertions, 0 deletions
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. * |