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:
authorMatthieu Aubry <mattab@users.noreply.github.com>2017-07-22 23:01:17 +0300
committerStefan Giehl <stefan@piwik.org>2017-07-22 23:01:17 +0300
commit7214a9b504a79955804e28dce1cdf7583588eb96 (patch)
tree1c2eba1147da524c7ea8c554c74630e28f7fd175
parent5387018f82e074a941ce4f50e37db68cb9066264 (diff)
When tracker is in maintenande mode return HTTP status code 503 (instead of the current 200 and 400 http status cods) (#11773)
* When tracker is in maintenande mode, return HTTP status code 503 instead of the current status of 200 or 400 This will make our return code consistent with the UI which also returns 503 while in maintenance mode Learn more about starting a maintenance window: https://piwik.org/faq/how-to-update/faq_154/ * Update TrackerResponseTest.php * Update TrackerResponseTest.php
-rw-r--r--core/Tracker.php5
-rw-r--r--core/Tracker/Response.php1
-rwxr-xr-xtests/PHPUnit/System/TrackerResponseTest.php10
3 files changed, 16 insertions, 0 deletions
diff --git a/core/Tracker.php b/core/Tracker.php
index 3ed757c638..43310c06a6 100644
--- a/core/Tracker.php
+++ b/core/Tracker.php
@@ -264,6 +264,11 @@ class Tracker
TrackerConfig::setConfigValue('enable_fingerprinting_across_websites', 1);
}
+ // Tests can simulate the tracker API maintenance mode
+ if (Common::getRequestVar('forceEnableTrackerMaintenanceMode', false, null, $args) == 1) {
+ TrackerConfig::setConfigValue('record_statistics', 0);
+ }
+
// Tests can force the use of 3rd party cookie for ID visitor
if (Common::getRequestVar('forceUseThirdPartyCookie', false, null, $args) == 1) {
TrackerConfig::setConfigValue('use_third_party_id_cookie', 1);
diff --git a/core/Tracker/Response.php b/core/Tracker/Response.php
index 7927666511..d5a01d7c24 100644
--- a/core/Tracker/Response.php
+++ b/core/Tracker/Response.php
@@ -71,6 +71,7 @@ class Response
public function outputResponse(Tracker $tracker)
{
if (!$tracker->shouldRecordStatistics()) {
+ Common::sendResponseCode(503);
$this->outputApiResponse($tracker);
Common::printDebug("Logging disabled, display transparent logo");
} elseif (!$tracker->hasLoggedRequests()) {
diff --git a/tests/PHPUnit/System/TrackerResponseTest.php b/tests/PHPUnit/System/TrackerResponseTest.php
index 05f6b749c3..98cd27baa0 100755
--- a/tests/PHPUnit/System/TrackerResponseTest.php
+++ b/tests/PHPUnit/System/TrackerResponseTest.php
@@ -114,4 +114,14 @@ class TrackerResponseTest extends SystemTestCase
$this->assertHttpResponseText($expected, $url);
}
+
+ public function test_response_ShouldReturnPiwikMessageWithHttp503_InCaseOfMaintenanceMode()
+ {
+ $url = $this->tracker->getUrlTrackPageView('Test');
+ $this->assertResponseCode(200, $url);
+
+ $url = $url . "&forceEnableTrackerMaintenanceMode=1";
+ $this->assertResponseCode(503, $url);
+ }
+
}