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-12-09 06:19:21 +0300
committerGitHub <noreply@github.com>2016-12-09 06:19:21 +0300
commit8aec36a019c1687aee46faf33db368766843cca7 (patch)
treee853c4bb4f35d34f88150d3eb060b72eaef66040
parentd530258efe4e3b9554c84eb98f6037867fffd55e (diff)
fix marketplace might not search for plugins correctly (#10986)
-rw-r--r--core/Http.php7
-rw-r--r--plugins/CoreUpdater/ReleaseChannel.php2
-rw-r--r--plugins/Installation/Controller.php2
-rw-r--r--plugins/Marketplace/Api/Client.php3
-rw-r--r--plugins/Marketplace/Api/Service.php2
-rw-r--r--plugins/Marketplace/tests/System/Api/ClientTest.php5
-rw-r--r--plugins/MobileMessaging/SMSProvider/Clockwork.php2
-rw-r--r--plugins/ScheduledReports/API.php3
-rw-r--r--tests/PHPUnit/Integration/HttpTest.php7
9 files changed, 24 insertions, 9 deletions
diff --git a/core/Http.php b/core/Http.php
index 373c4815d9..79ee0d2af3 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -162,7 +162,7 @@ class Http
$fileLength = 0;
if (!empty($requestBody) && is_array($requestBody)) {
- $requestBody = http_build_query($requestBody);
+ $requestBody = self::buildQuery($requestBody);
}
// Piwik services behave like a proxy, so we should act like one.
@@ -629,6 +629,11 @@ class Http
}
}
+ public static function buildQuery($params)
+ {
+ return http_build_query($params, '', '&');
+ }
+
private static function buildHeadersForPost($requestBody)
{
$postHeader = "Content-Type: application/x-www-form-urlencoded\r\n";
diff --git a/plugins/CoreUpdater/ReleaseChannel.php b/plugins/CoreUpdater/ReleaseChannel.php
index c7da77889f..23c84971a4 100644
--- a/plugins/CoreUpdater/ReleaseChannel.php
+++ b/plugins/CoreUpdater/ReleaseChannel.php
@@ -33,7 +33,7 @@ abstract class ReleaseChannel extends BaseReleaseChannel
$url = Config::getInstance()->General['api_service_url']
. '/1.0/getLatestVersion/'
- . '?' . http_build_query($parameters, '', '&');
+ . '?' . Http::buildQuery($parameters);
return $url;
}
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index 374acee4e3..6d3af32f46 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -738,7 +738,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
if (!isset($params['piwikpro'])) {
$params['piwikpro'] = '0';
}
- $url .= '?' . http_build_query($params, '', '&');
+ $url .= '?' . Http::buildQuery($params);
try {
Http::sendHttpRequest($url, $timeout = 2);
} catch (Exception $e) {
diff --git a/plugins/Marketplace/Api/Client.php b/plugins/Marketplace/Api/Client.php
index 0b4589f33a..254587233d 100644
--- a/plugins/Marketplace/Api/Client.php
+++ b/plugins/Marketplace/Api/Client.php
@@ -12,6 +12,7 @@ use Piwik\Cache;
use Piwik\Common;
use Piwik\Container\StaticContainer;
use Piwik\Filesystem;
+use Piwik\Http;
use Piwik\Plugin;
use Piwik\Plugins\Marketplace\Environment;
use Piwik\Plugins\Marketplace\Api\Service;
@@ -272,7 +273,7 @@ class Client
$params['num_users'] = $this->environment->getNumUsers();
$params['num_websites'] = $this->environment->getNumWebsites();
- $query = http_build_query($params);
+ $query = Http::buildQuery($params);
$cacheId = $this->getCacheKey($action, $query);
$result = $this->cache->fetch($cacheId);
diff --git a/plugins/Marketplace/Api/Service.php b/plugins/Marketplace/Api/Service.php
index e493b69941..7257d635d4 100644
--- a/plugins/Marketplace/Api/Service.php
+++ b/plugins/Marketplace/Api/Service.php
@@ -127,7 +127,7 @@ class Service
{
$endpoint = sprintf('%s/api/%s/', $this->domain, $this->version);
- $query = http_build_query($params);
+ $query = Http::buildQuery($params);
$url = sprintf('%s%s?%s', $endpoint, $action, $query);
$response = $this->download($url);
diff --git a/plugins/Marketplace/tests/System/Api/ClientTest.php b/plugins/Marketplace/tests/System/Api/ClientTest.php
index 8c3616321f..7011ebb837 100644
--- a/plugins/Marketplace/tests/System/Api/ClientTest.php
+++ b/plugins/Marketplace/tests/System/Api/ClientTest.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\Marketplace\tests\System\Api;
use Piwik\Cache;
+use Piwik\Http;
use Piwik\Plugin;
use Piwik\Plugins\Marketplace\Api\Client;
use Piwik\Plugins\Marketplace\Api\Service;
@@ -211,7 +212,7 @@ class ClientTest extends SystemTestCase
'num_users' => $this->environment->getNumUsers(),
'num_websites' => $this->environment->getNumWebsites()
);
- $id = 'marketplace.api.2.0.plugins.' . md5(http_build_query($params));
+ $id = 'marketplace.api.2.0.plugins.' . md5(Http::buildQuery($params));
$cache = $this->getCache();
$this->assertFalse($cache->contains($id));
@@ -240,7 +241,7 @@ class ClientTest extends SystemTestCase
'mysql' => $this->environment->getMySQLVersion(),
'num_users' => $this->environment->getNumUsers(),
'num_websites' => $this->environment->getNumWebsites());
- $id = 'marketplace.api.2.0.plugins.' . md5(http_build_query($params));
+ $id = 'marketplace.api.2.0.plugins.' . md5(Http::buildQuery($params));
$cache = $this->getCache();
$cache->save($id, array('plugins' => array(array('name' => 'foobar'))));
diff --git a/plugins/MobileMessaging/SMSProvider/Clockwork.php b/plugins/MobileMessaging/SMSProvider/Clockwork.php
index afda1fed76..572215d68c 100644
--- a/plugins/MobileMessaging/SMSProvider/Clockwork.php
+++ b/plugins/MobileMessaging/SMSProvider/Clockwork.php
@@ -91,7 +91,7 @@ class Clockwork extends SMSProvider
$url = self::BASE_API_URL
. $resource
- . '?' . http_build_query($parameters, '', '&');
+ . '?' . Http::buildQuery($parameters);
$timeout = self::SOCKET_TIMEOUT;
diff --git a/plugins/ScheduledReports/API.php b/plugins/ScheduledReports/API.php
index c4ab3e20c0..38a7923017 100644
--- a/plugins/ScheduledReports/API.php
+++ b/plugins/ScheduledReports/API.php
@@ -17,6 +17,7 @@ use Piwik\Date;
use Piwik\Db;
use Piwik\Development;
use Piwik\Filesystem;
+use Piwik\Http;
use Piwik\Log;
use Piwik\NoAccessException;
use Piwik\Piwik;
@@ -397,7 +398,7 @@ class API extends \Piwik\Plugin\API
} catch (\Exception $ex) {
// NOTE: can't use warning or error because the log message will appear in the UI as a notification
$this->logger->info("Error getting '?{report}' when generating scheduled report: {exception}", array(
- 'report' => http_build_query($params),
+ 'report' => Http::buildQuery($params),
'exception' => $ex->getMessage(),
));
diff --git a/tests/PHPUnit/Integration/HttpTest.php b/tests/PHPUnit/Integration/HttpTest.php
index 823b6037be..afa068bdf4 100644
--- a/tests/PHPUnit/Integration/HttpTest.php
+++ b/tests/PHPUnit/Integration/HttpTest.php
@@ -55,6 +55,13 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$this->assertGreaterThan(0, filesize($destinationPath));
}
+ public function testBuildQuery()
+ {
+ $this->assertEquals('', Http::buildQuery(array()));
+ $this->assertEquals('test=foo', Http::buildQuery(array('test' => 'foo')));
+ $this->assertEquals('test=foo&bar=baz', Http::buildQuery(array('test' => 'foo', 'bar' => 'baz')));
+ }
+
/**
* @dataProvider getMethodsToTest
*/