diff options
author | diosmosis <benaka@piwik.pro> | 2015-03-02 07:10:36 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-03-02 07:10:36 +0300 |
commit | ffb3390d93e623d632fc2ce2a6a4cc2927b1395a (patch) | |
tree | 5643c1c4ce8e48a40b901f99342113056a5d3991 /core | |
parent | ed3917deb266e059f3b25937feba0b442298a231 (diff) |
Rename UpdateListener to UpdateObserver and use in CLI update command to show progress of update. Also remove CLI output code from CoreUpdater\Controller::runUpdaterAndExit.
Diffstat (limited to 'core')
-rw-r--r-- | core/Columns/Updater.php | 8 | ||||
-rw-r--r-- | core/Plugin/Manager.php | 3 | ||||
-rw-r--r-- | core/Updater.php | 28 | ||||
-rw-r--r-- | core/Updater/UpdateObserver.php (renamed from core/Updater/UpdateListener.php) | 4 |
4 files changed, 19 insertions, 24 deletions
diff --git a/core/Columns/Updater.php b/core/Columns/Updater.php index 3de83592e8..093910a0f2 100644 --- a/core/Columns/Updater.php +++ b/core/Columns/Updater.php @@ -56,13 +56,7 @@ class Updater extends \Piwik\Updates public static function doUpdate(PiwikUpdater $updater) { foreach (self::getMigrationQueries($updater) as $sql => $errorCode) { - try { - Db::exec($sql); - } catch (\Exception $e) { - if (!Db::get()->isErrNo($e, '1091') && !Db::get()->isErrNo($e, '1060')) { - $updater->handleUpdateQueryError($e, $sql, false, __FILE__); - } - } + $updater->executeMigrationQuery($sql, $errorsToIgnore = array('1091', '1060'), __FILE__); } } diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 6e0d5ba91a..7b85c49a5a 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -1034,7 +1034,8 @@ class Manager extends Singleton $this->executePluginInstall($plugin); $pluginsInstalled[] = $pluginName; $this->updatePluginsInstalledConfig($pluginsInstalled); - Updater::recordComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion()); + $updater = new Updater(); + $updater->markComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion()); $saveConfig = true; } diff --git a/core/Updater.php b/core/Updater.php index 7f19a03ae3..3f90e2edd2 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -10,7 +10,7 @@ namespace Piwik; use Piwik\Columns\Updater as ColumnUpdater; use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException; -use Piwik\Updater\UpdateListener; +use Piwik\Updater\UpdateObserver; /** * Load and execute all relevant, incremental update scripts for Piwik core and plugins, and bump the component version numbers for completed updates. @@ -29,9 +29,9 @@ class Updater private $componentsWithUpdateFile = array(); /** - * @var UpdateListener[] + * @var UpdateObserver[] */ - private $updateListeners = array(); + private $updateObservers = array(); /** * @var Columns\Updater @@ -64,13 +64,13 @@ class Updater } /** - * Adds an UpdateListener to the internal list of listeners. + * Adds an UpdateObserver to the internal list of listeners. * - * @param UpdateListener $listener + * @param UpdateObserver $listener */ - public function addUpdateListener(UpdateListener $listener) + public function addUpdateObserver(UpdateObserver $listener) { - $this->updateListeners[] = $listener; + $this->updateObservers[] = $listener; } /** @@ -247,11 +247,11 @@ class Updater if (!in_array($className, $this->updatedClasses) && class_exists($className, false) ) { - $this->executeListenerHook('onComponentUpdateFileStarting', $componentName, $file, $className, $fileVersion); + $this->executeListenerHook('onComponentUpdateFileStarting', array($componentName, $file, $className, $fileVersion)); call_user_func(array($className, 'doUpdate'), $this); - $this->executeListenerHook('onComponentUpdateFileFinished', $componentName, $file, $className, $fileVersion); + $this->executeListenerHook('onComponentUpdateFileFinished', array($componentName, $file, $className, $fileVersion)); // makes sure to call Piwik\Columns\Updater only once as one call updates all dimensions at the same // time for better performance @@ -260,13 +260,13 @@ class Updater $this->markComponentSuccessfullyUpdated($componentName, $fileVersion); } catch (UpdaterErrorException $e) { - $this->executeListenerHook('onError', $componentName, $fileVersion, $e); + $this->executeListenerHook('onError', array($componentName, $fileVersion, $e)); throw $e; } catch (\Exception $e) { $warningMessages[] = $e->getMessage(); - $this->executeListenerHook('onWarning', $componentName, $fileVersion, $e); + $this->executeListenerHook('onWarning', array($componentName, $fileVersion, $e)); } } @@ -513,11 +513,11 @@ class Updater $this->executeListenerHook('onStartExecutingMigrationQuery', array($file, $migrationQuerySql)); Db::exec($migrationQuerySql); - - $this->executeListenerHook('onFinishedExecutingMigrationQuery', array($file, $migrationQuerySql)); } catch (\Exception $e) { $this->handleUpdateQueryError($e, $migrationQuerySql, $errorToIgnore, $file); } + + $this->executeListenerHook('onFinishedExecutingMigrationQuery', array($file, $migrationQuerySql)); } /** @@ -541,7 +541,7 @@ class Updater private function executeListenerHook($hookName, $arguments) { - foreach ($this->updateListeners as $listener) { + foreach ($this->updateObservers as $listener) { call_user_func_array(array($listener, $hookName), $arguments); } } diff --git a/core/Updater/UpdateListener.php b/core/Updater/UpdateObserver.php index deb3d458b2..b8a91562f5 100644 --- a/core/Updater/UpdateListener.php +++ b/core/Updater/UpdateObserver.php @@ -8,12 +8,12 @@ namespace Piwik\Updater; /** - * UpdateListeners can be used to inject logic into the component updating process. Derive + * UpdateObservers can be used to inject logic into the component updating process. Derive * from this base class and add an instance of the derived class to a Updater instance. When * Updater::update() is called, the methods in the added UpdateListeners will be executed * accordingly. */ -abstract class UpdateListener +abstract class UpdateObserver { /** * Executed when a component is about to be updated. At this point, no SQL queries or other |