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:
authorThomas Steur <tsteur@users.noreply.github.com>2016-09-29 00:00:17 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2016-09-29 00:00:17 +0300
commit2929e0c557d2dee09244ed25229409b1aac0af14 (patch)
tree0fa7881874b2c89d992e20625ba414fa24a45eb7 /plugins
parentcc96c2ec9bea5928d4255b50c5aa35b7dd05bc14 (diff)
Automatically update all marketplace plugins when updating Piwik (#10527)
* update plugins and piwik at the same time * make sure plugins are updated with piwik * use only one try/catch * reload plugin information once it has been installed * make sure to clear caches after an update * fix ui tests * make sure to use correct php version without any extras
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CorePluginsAdmin/MarketplaceApiClient.php10
-rw-r--r--plugins/CorePluginsAdmin/PluginInstaller.php9
-rw-r--r--plugins/CorePluginsAdmin/config/config.php7
-rw-r--r--plugins/CoreUpdater/Controller.php2
-rw-r--r--plugins/CoreUpdater/Updater.php54
-rw-r--r--plugins/CoreUpdater/lang/en.json4
6 files changed, 78 insertions, 8 deletions
diff --git a/plugins/CorePluginsAdmin/MarketplaceApiClient.php b/plugins/CorePluginsAdmin/MarketplaceApiClient.php
index 0423f72600..ee20abc918 100644
--- a/plugins/CorePluginsAdmin/MarketplaceApiClient.php
+++ b/plugins/CorePluginsAdmin/MarketplaceApiClient.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CorePluginsAdmin;
use Piwik\Cache;
+use Piwik\Container\StaticContainer;
use Piwik\Http;
use Piwik\Version;
@@ -123,9 +124,16 @@ class MarketplaceApiClient
return array();
}
+ public static function getPiwikVersion()
+ {
+ return StaticContainer::get('marketplacePiwikVersion');
+ }
+
private function fetch($action, $params)
{
ksort($params);
+ $params['piwik'] = self::getPiwikVersion();
+ $params['php'] = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
$query = http_build_query($params);
$cacheId = $this->getCacheKey($action, $query);
@@ -180,7 +188,7 @@ class MarketplaceApiClient
$latestVersion = array_pop($plugin['versions']);
$downloadUrl = $latestVersion['download'];
- return $this->domain . $downloadUrl . '?coreVersion=' . Version::VERSION;
+ return $this->domain . $downloadUrl . '?coreVersion=' . self::getPiwikVersion();
}
}
diff --git a/plugins/CorePluginsAdmin/PluginInstaller.php b/plugins/CorePluginsAdmin/PluginInstaller.php
index ed140d27bc..ab4f7b8622 100644
--- a/plugins/CorePluginsAdmin/PluginInstaller.php
+++ b/plugins/CorePluginsAdmin/PluginInstaller.php
@@ -12,6 +12,7 @@ use Piwik\Container\StaticContainer;
use Piwik\Filechecks;
use Piwik\Filesystem;
use Piwik\Piwik;
+use Piwik\Plugin\Manager as PluginManager;
use Piwik\Plugin\Dependency as PluginDependency;
use Piwik\Unzip;
@@ -49,6 +50,11 @@ class PluginInstaller
Filesystem::deleteAllCacheOnUpdate($this->pluginName);
+ $plugin = PluginManager::getInstance()->getLoadedPlugin($this->pluginName);
+ if (!empty($plugin)) {
+ $plugin->reloadPluginInformation();
+ }
+
} catch (\Exception $e) {
$this->removeFileIfExists($tmpPluginZip);
@@ -160,7 +166,10 @@ class PluginInstaller
$requires = (array) $metadata->require;
}
+ $piwikVersion = MarketplaceApiClient::getPiwikVersion();
+
$dependency = new PluginDependency();
+ $dependency->setPiwikVersion($piwikVersion);
$missingDependencies = $dependency->getMissingDependencies($requires);
if (!empty($missingDependencies)) {
diff --git a/plugins/CorePluginsAdmin/config/config.php b/plugins/CorePluginsAdmin/config/config.php
new file mode 100644
index 0000000000..5d30748a94
--- /dev/null
+++ b/plugins/CorePluginsAdmin/config/config.php
@@ -0,0 +1,7 @@
+<?php
+
+return array(
+ 'marketplacePiwikVersion' => function () {
+ return \Piwik\Version::VERSION;
+ }
+);
diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php
index df52b296aa..1122778cfb 100644
--- a/plugins/CoreUpdater/Controller.php
+++ b/plugins/CoreUpdater/Controller.php
@@ -98,6 +98,8 @@ class Controller extends \Piwik\Plugin\Controller
$messages = $e->getUpdateLogMessages();
}
+ Filesystem::deleteAllCacheOnUpdate();
+
$view->feedbackMessages = $messages;
$this->addCustomLogoInfo($view);
return $view->render();
diff --git a/plugins/CoreUpdater/Updater.php b/plugins/CoreUpdater/Updater.php
index 6912dba335..316f325690 100644
--- a/plugins/CoreUpdater/Updater.php
+++ b/plugins/CoreUpdater/Updater.php
@@ -10,17 +10,20 @@ namespace Piwik\Plugins\CoreUpdater;
use Exception;
use Piwik\ArchiveProcessor\Rules;
-use Piwik\Config;
+use Piwik\Container\StaticContainer;
use Piwik\Filechecks;
use Piwik\Filesystem;
use Piwik\Http;
use Piwik\Option;
use Piwik\Plugin\Manager as PluginManager;
use Piwik\Plugin\ReleaseChannels;
+use Piwik\Plugins\CorePluginsAdmin\CorePluginsAdmin;
+use Piwik\Plugins\CorePluginsAdmin\MarketplaceApiClient;
+use Piwik\Plugins\CorePluginsAdmin\MarketplaceApiException;
+use Piwik\Plugins\CorePluginsAdmin\PluginInstaller;
use Piwik\SettingsServer;
use Piwik\Translation\Translator;
use Piwik\Unzip;
-use Piwik\UpdateCheck;
use Piwik\Version;
class Updater
@@ -112,19 +115,58 @@ class Updater
$this->verifyDecompressedArchive($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles');
- $disabledPluginNames = $this->disableIncompatiblePlugins($newVersion);
- if (!empty($disabledPluginNames)) {
- $messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames));
- }
+ // we need to load the marketplace already here, otherwise it will use the new, updated file in Piwik 3
+ $marketplace = new MarketplaceApiClient();
+ require_once PIWIK_DOCUMENT_ROOT . '/plugins/CorePluginsAdmin/PluginInstaller.php';
+ require_once PIWIK_DOCUMENT_ROOT . '/plugins/CorePluginsAdmin/MarketplaceApiException.php';
$this->installNewFiles($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_InstallingTheLatestVersion');
+
} catch (ArchiveDownloadException $e) {
throw $e;
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
+ try {
+ if (CorePluginsAdmin::isMarketplaceEnabled()) {
+ $messages[] = $this->translator->translate('CoreUpdater_CheckingForPluginUpdates');
+
+ $pluginManager = PluginManager::getInstance();
+ $pluginManager->loadAllPluginsAndGetTheirInfo();
+ $loadedPlugins = $pluginManager->getLoadedPlugins();
+
+ MarketplaceApiClient::clearAllCacheEntries();
+ StaticContainer::getContainer()->set('marketplacePiwikVersion', $newVersion);
+
+ $pluginsWithUpdate = $marketplace->checkUpdates($loadedPlugins);
+
+ foreach ($pluginsWithUpdate as $pluginWithUpdate) {
+ $pluginName = $pluginWithUpdate['name'];
+
+ $messages[] = $this->translator->translate('CoreUpdater_UpdatingPluginXToVersionY',
+ array($pluginName, $pluginWithUpdate['version']));
+
+ $pluginInstaller = new PluginInstaller($pluginName);
+ $pluginInstaller->installOrUpdatePluginFromMarketplace();
+ }
+ }
+ } catch (MarketplaceApiException $e) {
+ // there is a problem with the connection to the server, ignore for now
+ } catch (Exception $e) {
+ throw new UpdaterException($e, $messages);
+ }
+
+ try {
+ $disabledPluginNames = $this->disableIncompatiblePlugins($newVersion);
+ if (!empty($disabledPluginNames)) {
+ $messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames));
+ }
+ } catch (Exception $e) {
+ throw new UpdaterException($e, $messages);
+ }
+
return $messages;
}
diff --git a/plugins/CoreUpdater/lang/en.json b/plugins/CoreUpdater/lang/en.json
index 8086f16b36..ad6d230ce9 100644
--- a/plugins/CoreUpdater/lang/en.json
+++ b/plugins/CoreUpdater/lang/en.json
@@ -1,5 +1,6 @@
{
"CoreUpdater": {
+ "CheckingForPluginUpdates": "Checking for new plugin updates",
"ClickHereToViewSqlQueries": "Click here to view and copy the list of SQL queries that will get executed",
"CriticalErrorDuringTheUpgradeProcess": "Critical Error during the update process:",
"DatabaseUpgradeRequired": "Database Upgrade Required",
@@ -23,7 +24,7 @@
"HelpMessageIntroductionWhenError": "The above is the core error message. It should help explain the cause, but if you require further help please:",
"HelpMessageIntroductionWhenWarning": "The update completed successfuly, however there were issues during the process. Please read the above descriptions for details. For further help:",
"HighTrafficPiwikServerEnableMaintenance": "If you manage a high traffic Piwik server, we recommend to %1$smomentarily disable visitor Tracking and put the Piwik User Interface in maintenance mode%2$s.",
- "IncompatbilePluginsWillBeDisabledInfo": "Note: some plugins are not compatible with Piwik %s. They will be disabled when you upgrade:",
+ "IncompatbilePluginsWillBeDisabledInfo": "Note: some plugins are not compatible with Piwik %s. We will update them if there is an update on the Marketplace, otherwise we will be disable them when you upgrade:",
"InstallingTheLatestVersion": "Installing the latest version",
"LatestBetaRelease": "Latest beta release",
"LatestStableRelease": "Latest stable release",
@@ -52,6 +53,7 @@
"UpdateAutomatically": "Update Automatically",
"UpdateHasBeenCancelledExplanation": "Piwik One Click Update has been cancelled. If you can't fix the above error message, it is recommended that you manually update Piwik. %1$s Please check out the %2$sUpdate documentation%3$s to get started!",
"UpdateTitle": "Update",
+ "UpdatingPluginXToVersionY": "Updating plugin %1$s to version %2$s",
"UpdateSuccessTitle": "Piwik has been successfully updated!",
"UpdateErrorTitle": "Update error",
"ThankYouUpdatePiwik": "Thank you for using Piwik and keeping it up to date!",