Skip to content
Extraits de code Groupes Projets
Valider bc561137 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Make sure core:update fails if an Updates class executes queries manually by...

Make sure core:update fails if an Updates class executes queries manually by catching them and re-throwing them.
parent 76d6b594
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -12,6 +12,7 @@ use Piwik\Columns\Updater as ColumnUpdater; ...@@ -12,6 +12,7 @@ use Piwik\Columns\Updater as ColumnUpdater;
use Piwik\Container\StaticContainer; use Piwik\Container\StaticContainer;
use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException; use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException;
use Piwik\Updater\UpdateObserver; 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. * 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 ...@@ -230,8 +231,7 @@ class Updater
) { ) {
$this->executeListenerHook('onComponentUpdateFileStarting', array($componentName, $file, $className, $fileVersion)); $this->executeListenerHook('onComponentUpdateFileStarting', array($componentName, $file, $className, $fileVersion));
$update = StaticContainer::getContainer()->make($className); $this->executeSingleUpdateClass($className);
call_user_func(array($update, 'doUpdate'), $this);
$this->executeListenerHook('onComponentUpdateFileFinished', array($componentName, $file, $className, $fileVersion)); $this->executeListenerHook('onComponentUpdateFileFinished', array($componentName, $file, $className, $fileVersion));
...@@ -528,6 +528,22 @@ class Updater ...@@ -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) * Performs database update(s)
* *
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter