diff options
Diffstat (limited to 'plugins/CoreUpdater/CoreUpdater.php')
-rw-r--r-- | plugins/CoreUpdater/CoreUpdater.php | 99 |
1 files changed, 14 insertions, 85 deletions
diff --git a/plugins/CoreUpdater/CoreUpdater.php b/plugins/CoreUpdater/CoreUpdater.php index f6f197db5d..584a465130 100644 --- a/plugins/CoreUpdater/CoreUpdater.php +++ b/plugins/CoreUpdater/CoreUpdater.php @@ -14,9 +14,8 @@ use Piwik\Common; use Piwik\Filesystem; use Piwik\FrontController; use Piwik\Piwik; -use Piwik\Columns\Updater as ColumnsUpdater; use Piwik\UpdateCheck; -use Piwik\Updater; +use Piwik\Updater as PiwikCoreUpdater; use Piwik\UpdaterErrorException; use Piwik\Version; @@ -36,89 +35,20 @@ class CoreUpdater extends \Piwik\Plugin ); } - public static function updateComponents(Updater $updater, $componentsWithUpdateFile) + /** + * @deprecated + */ + public static function updateComponents(PiwikCoreUpdater $updater, $componentsWithUpdateFile) { - $warnings = array(); - $errors = array(); - $deactivatedPlugins = array(); - $coreError = false; - - if (!empty($componentsWithUpdateFile)) { - $currentAccess = Access::getInstance(); - $hasSuperUserAccess = $currentAccess->hasSuperUserAccess(); - - if (!$hasSuperUserAccess) { - $currentAccess->setSuperUserAccess(true); - } - - // if error in any core update, show message + help message + EXIT - // if errors in any plugins updates, show them on screen, disable plugins that errored + CONTINUE - // if warning in any core update or in any plugins update, show message + CONTINUE - // if no error or warning, success message + CONTINUE - foreach ($componentsWithUpdateFile as $name => $filenames) { - try { - $warnings = array_merge($warnings, $updater->update($name)); - } catch (UpdaterErrorException $e) { - $errors[] = $e->getMessage(); - if ($name == 'core') { - $coreError = true; - break; - } elseif (\Piwik\Plugin\Manager::getInstance()->isPluginActivated($name)) { - \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($name); - $deactivatedPlugins[] = $name; - } - } - } - - if (!$hasSuperUserAccess) { - $currentAccess->setSuperUserAccess(false); - } - } - - Filesystem::deleteAllCacheOnUpdate(); - - $result = array( - 'warnings' => $warnings, - 'errors' => $errors, - 'coreError' => $coreError, - 'deactivatedPlugins' => $deactivatedPlugins - ); - - /** - * Triggered after Piwik has been updated. - */ - Piwik::postEvent('CoreUpdater.update.end'); - - return $result; + return $updater->updateComponents($componentsWithUpdateFile); } - public static function getComponentUpdates(Updater $updater) + /** + * @deprecated + */ + public static function getComponentUpdates(PiwikCoreUpdater $updater) { - $updater->addComponentToCheck('core', Version::VERSION); - $manager = \Piwik\Plugin\Manager::getInstance(); - $plugins = $manager->getLoadedPlugins(); - foreach ($plugins as $pluginName => $plugin) { - if ($manager->isPluginInstalled($pluginName)) { - $updater->addComponentToCheck($pluginName, $plugin->getVersion()); - } - } - - $columnsVersions = ColumnsUpdater::getAllVersions(); - foreach ($columnsVersions as $component => $version) { - $updater->addComponentToCheck($component, $version); - } - - $componentsWithUpdateFile = $updater->getComponentsWithUpdateFile(); - - if (count($componentsWithUpdateFile) == 0) { - ColumnsUpdater::onNoUpdateAvailable($columnsVersions); - - if (!$updater->hasNewVersion('core')) { - return null; - } - } - - return $componentsWithUpdateFile; + return $updater->getComponentUpdates(); } public function dispatch() @@ -126,13 +56,12 @@ class CoreUpdater extends \Piwik\Plugin $module = Common::getRequestVar('module', '', 'string'); $action = Common::getRequestVar('action', '', 'string'); - $updater = new Updater(); - $updater->addComponentToCheck('core', Version::VERSION); - $updates = $updater->getComponentsWithNewVersion(); + $updater = new PiwikCoreUpdater(); + $updates = $updater->getComponentsWithNewVersion(array('core' => Version::VERSION)); if (!empty($updates)) { Filesystem::deleteAllCacheOnUpdate(); } - if (self::getComponentUpdates($updater) !== null + if ($updater->getComponentUpdates() !== null && $module != 'CoreUpdater' // Proxy module is used to redirect users to piwik.org, should still work when Piwik must be updated && $module != 'Proxy' |