diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-09-17 00:35:15 +0300 |
---|---|---|
committer | Thomas Steur <tsteur@users.noreply.github.com> | 2018-09-17 00:35:15 +0300 |
commit | ca585d9905a831441a148285e8138040e8e07284 (patch) | |
tree | bb3c7e03912c89d2faae9c0a48d5ef9bd9e95e1f /plugins/SegmentEditor | |
parent | f0a9628bccad7cbb0005669f39578b122849a573 (diff) |
When displaying unprocessed segment message, check for urlencoded segment. (#13415)
* When displaying unprocessed message, check for urlencoded segment.
* Add test.
Diffstat (limited to 'plugins/SegmentEditor')
3 files changed, 31 insertions, 1 deletions
diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php index 2ede0215a8..3bdf06b3d2 100644 --- a/plugins/SegmentEditor/SegmentEditor.php +++ b/plugins/SegmentEditor/SegmentEditor.php @@ -199,7 +199,13 @@ class SegmentEditor extends \Piwik\Plugin // data does not exist. this means the data will be processed later. we let the user know so they will not // be confused. $model = new Model(); - $storedSegment = $model->getSegmentByDefinition($segment->getString()) ?: null; + $storedSegment = $model->getSegmentByDefinition($segment->getString()); + if (empty($storedSegment)) { + $storedSegment = $model->getSegmentByDefinition(urldecode($segment->getString())); + } + if (empty($storedSegment)) { + $storedSegment = null; + } return [$segment, $storedSegment, $isSegmentToPreprocess]; } diff --git a/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php b/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php index e4d3d45c17..dbc7cae23b 100644 --- a/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php +++ b/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php @@ -87,6 +87,26 @@ class UnprocessedSegmentsTest extends IntegrationTestCase ]); } + public function test_apiOutput_whenUnprocessedAutoArchiveSegmentUsed_WithBrowserArchivingDisabled_AndEncodedSegment() + { + $idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true); + + $storedSegment = API::getInstance()->get($idSegment); + $this->assertNotEmpty($storedSegment); + + Rules::setBrowserTriggerArchiving(false); + + $segments = Rules::getSegmentsToProcess([self::$fixture->idSite]); + $this->assertContains(self::TEST_SEGMENT, $segments); + + $this->runAnyApiTest('VisitsSummary.get', 'autoArchiveSegmentUnprocessedEncoded', [ + 'idSite' => self::$fixture->idSite, + 'date' => Date::factory(self::$fixture->dateTime)->toString(), + 'period' => 'week', + 'segment' => urlencode(self::TEST_SEGMENT), + ]); + } + public function test_apiOutput_whenPreprocessedSegmentUsed_WithBrowserArchivingDisabled() { $idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true); diff --git a/plugins/SegmentEditor/tests/System/expected/test___VisitsSummary.get_autoArchiveSegmentUnprocessedEncoded.xml b/plugins/SegmentEditor/tests/System/expected/test___VisitsSummary.get_autoArchiveSegmentUnprocessedEncoded.xml new file mode 100644 index 0000000000..57b75e01db --- /dev/null +++ b/plugins/SegmentEditor/tests/System/expected/test___VisitsSummary.get_autoArchiveSegmentUnprocessedEncoded.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <error message="These reports have no data, because the Segment you requested (testsegment) has not yet been processed by the system. Data for this Segment should become available in a few hours when processing completes. (If it does not, there may be a problem.) Please note that you can test whether your segment will work without having to wait for it to be processed by using the Live.getLastVisitsDetails API. When using this API method, you will see which users and actions were matched by your &segment= parameter. This can help you confirm your Segment matches the users and actions you expect it to." /> +</result>
\ No newline at end of file |