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>2019-03-13 04:16:30 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-03-13 04:16:30 +0300
commit7393e13b1cd8deda984037192d3d9c13e3cd67aa (patch)
tree374454eb3ae55ad256881058855c48312fb1e09e /plugins/Installation
parentdef74364a2d821d5dddaceece76c217547b99d14 (diff)
When dispatch is disabled via a constant, it should not be dispatched (#14034)
* When dispatch is disabled via a constant, it should not be dispatched Eg when Matomo is not installed, it would still dispatch the request in https://github.com/matomo-org/matomo/blob/3.8.1-b1/plugins/Installation/Installation.php#L111 even when `PIWIK_ENABLE_DISPATCH` is disabled. Will set it to WIP for now as I'm not sure if we want to have this actually merged or not. * Update Installation.php * Use correct exception class * throw exception if one is given * adding a test * fix tests * trying to fix test
Diffstat (limited to 'plugins/Installation')
-rw-r--r--plugins/Installation/Installation.php7
-rw-r--r--plugins/Installation/tests/System/APITest.php7
2 files changed, 13 insertions, 1 deletions
diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php
index aa4ff1c6df..a1d2964343 100644
--- a/plugins/Installation/Installation.php
+++ b/plugins/Installation/Installation.php
@@ -107,8 +107,13 @@ class Installation extends \Piwik\Plugin
$action = Common::getRequestVar('action', 'welcome', 'string');
- if ($this->isAllowedAction($action)) {
+ if ($this->isAllowedAction($action) && (!defined('PIWIK_ENABLE_DISPATCH') || PIWIK_ENABLE_DISPATCH)) {
echo FrontController::getInstance()->dispatch('Installation', $action, array($message));
+ } elseif (defined('PIWIK_ENABLE_DISPATCH') && !PIWIK_ENABLE_DISPATCH) {
+ if ($exception && $exception instanceof \Exception) {
+ throw $exception;
+ }
+ return;
} else {
Piwik::exitWithErrorMessage($this->getMessageToInviteUserToInstallPiwik($message));
}
diff --git a/plugins/Installation/tests/System/APITest.php b/plugins/Installation/tests/System/APITest.php
index d8ae5523c8..887e5e17ba 100644
--- a/plugins/Installation/tests/System/APITest.php
+++ b/plugins/Installation/tests/System/APITest.php
@@ -61,6 +61,13 @@ class APITest extends SystemTestCase
$this->assertContains('Access denied', $data);
}
+ public function test_shouldReturnEmptyResultWhenNotInstalledAndDispatchIsDisabled()
+ {
+ $url = Fixture::getTestRootUrl() . 'nodispatchnotinstalled.php';
+ $response = $this->sendHttpRequest($url);
+ $this->assertSame('', $response['data']);
+ }
+
private function getUrl()
{
return Fixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php?module=API&method=API.getPiwikVersion';