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 <thomas.steur@gmail.com>2015-08-31 16:42:07 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-09-22 15:47:08 +0300
commit8f97ef8dee78aa1fd0bba12f34cd4512ee5959cc (patch)
treeab2f7e57660990d951029b5a6d282265b0ba0cbf /plugins/CoreUpdater
parent9611d739b69bd188462588d0b8a0463ea8ae6fde (diff)
refs #8549 support for multiple release channels
Diffstat (limited to 'plugins/CoreUpdater')
-rw-r--r--plugins/CoreUpdater/ReleaseChannel.php43
-rw-r--r--plugins/CoreUpdater/ReleaseChannel/Latest2XBeta.php35
-rw-r--r--plugins/CoreUpdater/ReleaseChannel/Latest2XStable.php35
-rw-r--r--plugins/CoreUpdater/ReleaseChannel/LatestBeta.php30
-rw-r--r--plugins/CoreUpdater/ReleaseChannel/LatestStable.php40
-rw-r--r--plugins/CoreUpdater/Test/Integration/ReleaseChannelTest.php66
-rw-r--r--plugins/CoreUpdater/Test/Mock/UpdaterMock.php5
-rw-r--r--plugins/CoreUpdater/Updater.php19
-rw-r--r--plugins/CoreUpdater/lang/en.json5
9 files changed, 270 insertions, 8 deletions
diff --git a/plugins/CoreUpdater/ReleaseChannel.php b/plugins/CoreUpdater/ReleaseChannel.php
new file mode 100644
index 0000000000..cb1ea5c9df
--- /dev/null
+++ b/plugins/CoreUpdater/ReleaseChannel.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreUpdater;
+
+use Piwik\Common;
+use Piwik\Config;
+use Piwik\Http;
+use Piwik\Plugins\SitesManager\API;
+use Piwik\Url;
+use Piwik\Version;
+use Piwik\UpdateCheck\ReleaseChannel as BaseReleaseChannel;
+
+abstract class ReleaseChannel extends BaseReleaseChannel
+{
+ public function getUrlToCheckForLatestAvailableVersion()
+ {
+ $parameters = array(
+ 'piwik_version' => Version::VERSION,
+ 'php_version' => PHP_VERSION,
+ 'release_channel' => $this->getId(),
+ 'url' => Url::getCurrentUrlWithoutQueryString(),
+ 'trigger' => Common::getRequestVar('module', '', 'string'),
+ 'timezone' => API::getInstance()->getDefaultTimezone(),
+ );
+
+ $url = Config::getInstance()->General['api_service_url']
+ . '/1.0/getLatestVersion/'
+ . '?' . http_build_query($parameters, '', '&');
+
+ return $url;
+ }
+
+ public function getDownloadUrlWithoutScheme($version)
+ {
+ return sprintf('://builds.piwik.org/piwik-%s.zip', $version);
+ }
+} \ No newline at end of file
diff --git a/plugins/CoreUpdater/ReleaseChannel/Latest2XBeta.php b/plugins/CoreUpdater/ReleaseChannel/Latest2XBeta.php
new file mode 100644
index 0000000000..6ff410e7e4
--- /dev/null
+++ b/plugins/CoreUpdater/ReleaseChannel/Latest2XBeta.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+use Piwik\Piwik;
+use Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+class Latest2XBeta extends ReleaseChannel
+{
+ public function getId()
+ {
+ return 'latest_2x_beta';
+ }
+
+ public function getName()
+ {
+ return Piwik::translate('CoreUpdater_Latest2XBetaRelease');
+ }
+
+ public function getDescription()
+ {
+ return Piwik::translate('CoreUpdater_LtsSupportVersion');
+ }
+
+ public function getOrder()
+ {
+ return 21;
+ }
+} \ No newline at end of file
diff --git a/plugins/CoreUpdater/ReleaseChannel/Latest2XStable.php b/plugins/CoreUpdater/ReleaseChannel/Latest2XStable.php
new file mode 100644
index 0000000000..e4c905d506
--- /dev/null
+++ b/plugins/CoreUpdater/ReleaseChannel/Latest2XStable.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+use Piwik\Piwik;
+use Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+class Latest2XStable extends ReleaseChannel
+{
+ public function getId()
+ {
+ return 'latest_2x_stable';
+ }
+
+ public function getName()
+ {
+ return Piwik::translate('CoreUpdater_Latest2XStableRelease');
+ }
+
+ public function getDescription()
+ {
+ return Piwik::translate('CoreUpdater_LtsSupportVersion');
+ }
+
+ public function getOrder()
+ {
+ return 20;
+ }
+} \ No newline at end of file
diff --git a/plugins/CoreUpdater/ReleaseChannel/LatestBeta.php b/plugins/CoreUpdater/ReleaseChannel/LatestBeta.php
new file mode 100644
index 0000000000..53b1c33975
--- /dev/null
+++ b/plugins/CoreUpdater/ReleaseChannel/LatestBeta.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+use Piwik\Piwik;
+use Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+class LatestBeta extends ReleaseChannel
+{
+ public function getId()
+ {
+ return 'latest_beta';
+ }
+
+ public function getName()
+ {
+ return Piwik::translate('CoreUpdater_LatestBetaRelease');
+ }
+
+ public function getOrder()
+ {
+ return 11;
+ }
+} \ No newline at end of file
diff --git a/plugins/CoreUpdater/ReleaseChannel/LatestStable.php b/plugins/CoreUpdater/ReleaseChannel/LatestStable.php
new file mode 100644
index 0000000000..1a7088ab10
--- /dev/null
+++ b/plugins/CoreUpdater/ReleaseChannel/LatestStable.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+use Piwik\Piwik;
+use Piwik\Plugins\CoreUpdater\ReleaseChannel;
+
+class LatestStable extends ReleaseChannel
+{
+ public function getId()
+ {
+ return 'latest_stable';
+ }
+
+ public function getName()
+ {
+ return Piwik::translate('CoreUpdater_LatestStableRelease');
+ }
+
+ public function getDescription()
+ {
+ return Piwik::translate('General_Recommended');
+ }
+
+ public function getDownloadUrlWithoutScheme($version)
+ {
+ return '://builds.piwik.org/piwik.zip';
+ }
+
+ public function getOrder()
+ {
+ return 10;
+ }
+} \ No newline at end of file
diff --git a/plugins/CoreUpdater/Test/Integration/ReleaseChannelTest.php b/plugins/CoreUpdater/Test/Integration/ReleaseChannelTest.php
new file mode 100644
index 0000000000..3f1f4248b4
--- /dev/null
+++ b/plugins/CoreUpdater/Test/Integration/ReleaseChannelTest.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CoreUpdater\Test\ReleaseChannel;
+
+use Piwik\Config;
+use Piwik\Plugins\CoreUpdater\ReleaseChannel;
+use Piwik\UpdateCheck;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+use Piwik\Url;
+use Piwik\Version;
+
+class MyReleaseChannel extends ReleaseChannel
+{
+ public function getId()
+ {
+ return 'my_channel';
+ }
+
+ public function getName()
+ {
+ return 'My Special Channel';
+ }
+}
+
+/**
+ * @group Plugins
+ * @group ReleaseChannel
+ * @group ReleaseChannelTest
+ */
+class ReleaseChannelTest extends IntegrationTestCase
+{
+ /**
+ * @var MyReleaseChannel
+ */
+ private $channel;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->channel = new MyReleaseChannel();
+ }
+
+ public function test_getDownloadUrlWithoutScheme_shouldReturnUrlWithVersionNumberButWithoutScheme()
+ {
+ $this->assertSame('://builds.piwik.org/piwik-2.15.0-b5.zip', $this->channel->getDownloadUrlWithoutScheme('2.15.0-b5'));
+ }
+
+ public function test_getUrlToCheckForLatestAvailableVersion()
+ {
+ $version = Version::VERSION;
+ $phpVersion = urlencode(PHP_VERSION);
+ $url = urlencode(Url::getCurrentUrlWithoutQueryString());
+
+ $urlToCheck = $this->channel->getUrlToCheckForLatestAvailableVersion();
+
+ $this->assertStringStartsWith("http://api.piwik.org/1.0/getLatestVersion/?piwik_version=$version&php_version=$phpVersion&release_channel=my_channel&url=$url&trigger=&timezone=", $urlToCheck);
+ }
+
+}
diff --git a/plugins/CoreUpdater/Test/Mock/UpdaterMock.php b/plugins/CoreUpdater/Test/Mock/UpdaterMock.php
index 7a73129c5b..2821538b09 100644
--- a/plugins/CoreUpdater/Test/Mock/UpdaterMock.php
+++ b/plugins/CoreUpdater/Test/Mock/UpdaterMock.php
@@ -34,6 +34,11 @@ class UpdaterMock extends Updater
return true;
}
+ public function getArchiveUrl()
+ {
+ return 'http://builds.piwik.org/piwik.zip';
+ }
+
public function updatePiwik($https = true)
{
// Simulate that the update over HTTPS fails
diff --git a/plugins/CoreUpdater/Updater.php b/plugins/CoreUpdater/Updater.php
index acbc77e35d..6912dba335 100644
--- a/plugins/CoreUpdater/Updater.php
+++ b/plugins/CoreUpdater/Updater.php
@@ -16,17 +16,17 @@ use Piwik\Filesystem;
use Piwik\Http;
use Piwik\Option;
use Piwik\Plugin\Manager as PluginManager;
+use Piwik\Plugin\ReleaseChannels;
use Piwik\SettingsServer;
use Piwik\Translation\Translator;
use Piwik\Unzip;
+use Piwik\UpdateCheck;
use Piwik\Version;
class Updater
{
const OPTION_LATEST_VERSION = 'UpdateCheck_LatestVersion';
const PATH_TO_EXTRACT_LATEST_VERSION = '/latest/';
- const LATEST_VERSION_URL = '://builds.piwik.org/piwik.zip';
- const LATEST_BETA_VERSION_URL = '://builds.piwik.org/piwik-%s.zip';
const DOWNLOAD_TIMEOUT = 720;
/**
@@ -35,13 +35,19 @@ class Updater
private $translator;
/**
+ * @var ReleaseChannels
+ */
+ private $releaseChannels;
+
+ /**
* @var string
*/
private $tmpPath;
- public function __construct(Translator $translator, $tmpPath)
+ public function __construct(Translator $translator, ReleaseChannels $releaseChannels, $tmpPath)
{
$this->translator = $translator;
+ $this->releaseChannels = $releaseChannels;
$this->tmpPath = $tmpPath;
}
@@ -252,11 +258,8 @@ class Updater
*/
public function getArchiveUrl($version, $https = true)
{
- if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) {
- $url = sprintf(self::LATEST_BETA_VERSION_URL, $version);
- } else {
- $url = self::LATEST_VERSION_URL;
- }
+ $channel = $this->releaseChannels->getActiveReleaseChannel();
+ $url = $channel->getDownloadUrlWithoutScheme($version);
if ($this->isUpdatingOverHttps() && $https) {
$url = 'https' . $url;
diff --git a/plugins/CoreUpdater/lang/en.json b/plugins/CoreUpdater/lang/en.json
index 8429c9b597..cb3f8a1c6a 100644
--- a/plugins/CoreUpdater/lang/en.json
+++ b/plugins/CoreUpdater/lang/en.json
@@ -25,6 +25,11 @@
"HighTrafficPiwikServerEnableMaintenance": "If you manage a high traffic Piwik server, we recommend to %smomentarily disable visitor Tracking and put the Piwik User Interface in maintenance mode%s.",
"IncompatbilePluginsWillBeDisabledInfo": "Note: some plugins are not compatible with Piwik %s. They will be disabled when you upgrade:",
"InstallingTheLatestVersion": "Installing the latest version",
+ "LatestBetaRelease": "Latest beta release",
+ "LatestStableRelease": "Latest stable release",
+ "Latest2XStableRelease": "Latest stable 2.X",
+ "Latest2XBetaRelease": "Latest beta 2.X",
+ "LtsSupportVersion": "Long Term Support version",
"MajorUpdateWarning1": "This is a major update! It will take longer than usual.",
"MajorUpdateWarning2": "The following advice is especially important for large installations.",
"NoteForLargePiwikInstances": "Important notes for large Piwik installations",