diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-07-11 08:59:25 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-07-11 08:59:25 +0400 |
commit | 432edcc856086e1f93436653331c82169bd4ff4b (patch) | |
tree | 42276f514da6c7678cd8832c610613655d6495b6 /core/Updater.php | |
parent | b4b7cd4473c0ee1dfb331ec5a8d33a3143d9d8a3 (diff) |
Fixes #5809, change existing SQL to ignore errors that occur when updates are executed more than once, add test for multiple update and allow updates to specify more than one error code to ignore.
Diffstat (limited to 'core/Updater.php')
-rw-r--r-- | core/Updater.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/Updater.php b/core/Updater.php index 6d46bbf147..8b272cde66 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -313,12 +313,29 @@ class Updater public static function handleQueryError($e, $updateSql, $errorToIgnore, $file) { if (($errorToIgnore === false) - || !Db::get()->isErrNo($e, $errorToIgnore) + || !self::isDbErrorOneOf($e, $errorToIgnore) ) { $message = $file . ":\nError trying to execute the query '" . $updateSql . "'.\nThe error was: " . $e->getMessage(); throw new UpdaterErrorException($message); } } + + /** + * Returns whether an exception is a DB error with a code in the $errorCodesToIgnore list. + * + * @param int $error + * @param int|int[] $errorCodesToIgnore + */ + public static function isDbErrorOneOf($error, $errorCodesToIgnore) + { + $errorCodesToIgnore = is_array($errorCodesToIgnore) ? $errorCodesToIgnore : array($errorCodesToIgnore); + foreach ($errorCodesToIgnore as $code) { + if (Db::get()->isErrNo($error, $code)) { + return true; + } + } + return false; + } } /** @@ -327,4 +344,4 @@ class Updater */ class UpdaterErrorException extends \Exception { -} +}
\ No newline at end of file |