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:
authordiosmosis <diosmosis@users.noreply.github.com>2018-08-17 13:31:37 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2018-08-17 13:31:37 +0300
commit46ed8c2eef4990688c1188b31bc8d8229087daab (patch)
tree6c443b84f2762efdafab8c583db716d484b458d0
parent4ba679f716d18900c82a3cd1a0d303d72e59b9ff (diff)
Do not serialize every property of Periods which can appear in DataTable metadata. (#13280)
* Do not serialize every property of Periods which can appear in DataTable metadata. * Add test for original PHP serialized response.
-rw-r--r--core/Period.php12
-rw-r--r--core/Period/Range.php20
-rw-r--r--plugins/Referrers/tests/System/ApiTest.php11
-rw-r--r--plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.originalbin0 -> 2379 bytes
4 files changed, 43 insertions, 0 deletions
diff --git a/core/Period.php b/core/Period.php
index ebcad4896d..8cd849ba41 100644
--- a/core/Period.php
+++ b/core/Period.php
@@ -65,6 +65,18 @@ abstract class Period
$this->translator = StaticContainer::get('Piwik\Translation\Translator');
}
+ public function __sleep()
+ {
+ return [
+ 'date',
+ ];
+ }
+
+ public function __wakeup()
+ {
+ $this->translator = StaticContainer::get('Piwik\Translation\Translator');
+ }
+
/**
* Returns true if `$dateString` and `$period` represent multiple periods.
*
diff --git a/core/Period/Range.php b/core/Period/Range.php
index 7073ad2c16..579fa22aa3 100644
--- a/core/Period/Range.php
+++ b/core/Period/Range.php
@@ -40,6 +40,10 @@ class Range extends Period
*/
protected $defaultEndDate;
+ protected $strPeriod;
+ protected $strDate;
+ protected $timezone;
+
/**
* Constructor.
*
@@ -66,6 +70,22 @@ class Range extends Period
$this->translator = StaticContainer::get('Piwik\Translation\Translator');
}
+ public function __sleep()
+ {
+ return [
+ 'strPeriod',
+ 'strDate',
+ 'timezone',
+ 'defaultEndDate',
+ 'today',
+ ];
+ }
+
+ public function __wakeup()
+ {
+ $this->translator = StaticContainer::get('Piwik\Translation\Translator');
+ }
+
private function getCache()
{
return Cache::getTransientCache();
diff --git a/plugins/Referrers/tests/System/ApiTest.php b/plugins/Referrers/tests/System/ApiTest.php
index fb91e57ca2..0778f0f7ea 100644
--- a/plugins/Referrers/tests/System/ApiTest.php
+++ b/plugins/Referrers/tests/System/ApiTest.php
@@ -55,6 +55,17 @@ class ApiTest extends SystemTestCase
)
);
+ $apiToTest[] = [
+ 'Referrers.getReferrerType',
+ [
+ 'idSite' => 1,
+ 'date' => '2010-01-01',
+ 'periods' => 'year',
+ 'testSuffix' => 'phpSerialized',
+ 'format' => 'original',
+ ],
+ ];
+
return $apiToTest;
}
diff --git a/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original b/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original
new file mode 100644
index 0000000000..c7b55583d7
--- /dev/null
+++ b/plugins/Referrers/tests/System/expected/test_phpSerialized__Referrers.getReferrerType_year.original
Binary files differ