diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-04-03 09:49:36 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-04-03 09:49:36 +0400 |
commit | 263b0700c9f700bc00749fbadc0f67f4bc478b26 (patch) | |
tree | bd3d6bf9329f425be907208cef3a74a1e62f3f2e /core/Updater.php | |
parent | 6008898c699521e34a5b6156d54787f66eb9450b (diff) |
Refs #4878, create update script for converting *_returning metrics to new segmented metrics. Removed Archiver and API. Old segmented VisitFrequency metrics will not be accessible.
Diffstat (limited to 'core/Updater.php')
-rw-r--r-- | core/Updater.php | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/core/Updater.php b/core/Updater.php index 59587cb19b..a1f39fb71b 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -287,16 +287,41 @@ class Updater static function updateDatabase($file, $sqlarray) { foreach ($sqlarray as $update => $ignoreError) { - try { - Db::exec($update); - } catch (\Exception $e) { - if (($ignoreError === false) - || !Db::get()->isErrNo($e, $ignoreError) - ) { - $message = $file . ":\nError trying to execute the query '" . $update . "'.\nThe error was: " . $e->getMessage(); - throw new UpdaterErrorException($message); - } - } + self::executeMigrationQuery($update, $ignoreError, $file); + } + } + + /** + * Executes a database update query. + * + * @param string $updateSql Update SQL query. + * @param int|false $errorToIgnore A MySQL error code to ignore. + * @param string $file The Update file that's calling this method. + */ + public static function executeMigrationQuery($updateSql, $errorToIgnore, $file) + { + try { + Db::exec($updateSql); + } catch (\Exception $e) { + self::handleQueryError($e, $updateSql, $errorToIgnore, $file); + } + } + + /** + * Handle an error that is thrown from a database query. + * + * @param \Exception $e the exception thrown. + * @param string $updateSql Update SQL query. + * @param int|false $errorToIgnore A MySQL error code to ignore. + * @param string $file The Update file that's calling this method. + */ + public static function handleQueryError($e, $updateSql, $errorToIgnore, $file) + { + if (($errorToIgnore === false) + || !Db::get()->isErrNo($e, $errorToIgnore) + ) { + $message = $file . ":\nError trying to execute the query '" . $updateSql . "'.\nThe error was: " . $e->getMessage(); + throw new UpdaterErrorException($message); } } } |