Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-03-16 21:58:59 +0300
committerdiosmosis <benaka@piwik.pro>2015-03-16 21:58:59 +0300
commitbc561137c99cecbaa3b14a44a2dc259be38c778e (patch)
treef887c888e17832e33b58a8dd4d02065d9a59010e /core/Updater.php
parent76d6b594c02bb8a1f99e0c7e0a539103275a491b (diff)
Make sure core:update fails if an Updates class executes queries manually by catching them and re-throwing them.
Diffstat (limited to 'core/Updater.php')
-rw-r--r--core/Updater.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/core/Updater.php b/core/Updater.php
index dad7116177..bccddff3f2 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -12,6 +12,7 @@ use Piwik\Columns\Updater as ColumnUpdater;
use Piwik\Container\StaticContainer;
use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException;
use Piwik\Updater\UpdateObserver;
+use Zend_Db_Exception;
/**
* Load and execute all relevant, incremental update scripts for Piwik core and plugins, and bump the component version numbers for completed updates.
@@ -230,8 +231,7 @@ class Updater
) {
$this->executeListenerHook('onComponentUpdateFileStarting', array($componentName, $file, $className, $fileVersion));
- $update = StaticContainer::getContainer()->make($className);
- call_user_func(array($update, 'doUpdate'), $this);
+ $this->executeSingleUpdateClass($className);
$this->executeListenerHook('onComponentUpdateFileFinished', array($componentName, $file, $className, $fileVersion));
@@ -528,6 +528,22 @@ class Updater
}
}
+ private function executeSingleUpdateClass($className)
+ {
+ $update = StaticContainer::getContainer()->make($className);
+ try {
+ call_user_func(array($update, 'doUpdate'), $this);
+ } catch (\Exception $e) {
+ // if an Update file executes PHP statements directly, DB exceptions be handled by executeSingleMigrationQuery, so
+ // make sure to check for them here
+ if ($e instanceof Zend_Db_Exception) {
+ throw new UpdaterErrorException($e->getMessage(), $e->getCode(), $e);
+ } else {
+ throw $e;
+ }
+ }
+ }
+
/**
* Performs database update(s)
*