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:
authorPeter Zhang <peter@innocraft.com>2022-01-26 03:16:57 +0300
committerGitHub <noreply@github.com>2022-01-26 03:16:57 +0300
commitda4be81ebbe1e9225e2ac7b4eb8c272e33eeb088 (patch)
treecc4e58731ccabc576e396242a48c26768aa64e2c
parenta0705d8fd53f3818c517fa386c0e377196937942 (diff)
Revert "add date, period params into common function (#18653)" (#18685)
This reverts commit a0705d8fd53f3818c517fa386c0e377196937942.
-rw-r--r--core/Piwik.php12
-rw-r--r--core/Plugin/Controller.php27
-rw-r--r--plugins/MultiSites/Controller.php4
-rw-r--r--plugins/VisitsSummary/Reports/Get.php2
4 files changed, 21 insertions, 24 deletions
diff --git a/core/Piwik.php b/core/Piwik.php
index 3ac780324b..e0c25d81d3 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -185,7 +185,7 @@ class Piwik
$user = APIUsersManager::getInstance()->getUser(Piwik::getCurrentUserLogin());
return $user['date_registered'] ?? '';
}
-
+
/**
* Returns the current user's Last Seen.
*
@@ -889,14 +889,4 @@ class Piwik
return $translator->translate($translationId, $args, $language);
}
-
- public static function getPeriod($default = null)
- {
- return Common::getRequestVar('period', $default, 'string');
- }
-
- public static function getDate($default = null)
- {
- return Common::getRequestVar('date', $default, 'string');
- }
}
diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php
index 953fd7eed2..ca2f169895 100644
--- a/core/Plugin/Controller.php
+++ b/core/Plugin/Controller.php
@@ -476,18 +476,25 @@ abstract class Controller
*/
protected function getGraphParamsModified($paramsToSet = array())
{
- try {
- $period = isset($paramsToSet['period']) ?? Piwik::getPeriod();
- } catch (\Exception $e) {
- $period = null;
+ if (!isset($paramsToSet['period'])) {
+ $period = Common::getRequestVar('period');
+ } else {
+ $period = $paramsToSet['period'];
}
-
if ($period === 'range') {
return $paramsToSet;
}
+ if (!isset($paramsToSet['range'])) {
+ $range = 'last30';
+ } else {
+ $range = $paramsToSet['range'];
+ }
- $range = isset($paramsToSet['range']) ?? 'last30';
- $endDate = isset($paramsToSet['date']) ?? $this->strDate;
+ if (!isset($paramsToSet['date'])) {
+ $endDate = $this->strDate;
+ } else {
+ $endDate = $paramsToSet['date'];
+ }
if (is_null($this->site)) {
throw new NoAccessException("Website not initialized, check that you are logged in and/or using the correct token_auth.");
@@ -633,10 +640,10 @@ abstract class Controller
$maxDate = Date::factory('now', $siteTimezone);
$this->setMaxDateView($maxDate, $view);
- $rawDate = Piwik::getDate();
+ $rawDate = Common::getRequestVar('date');
Period::checkDateFormat($rawDate);
- $periodStr = Piwik::getPeriod();
+ $periodStr = Common::getRequestVar('period');
if ($periodStr !== 'range') {
$date = Date::factory($this->strDate);
@@ -916,7 +923,7 @@ abstract class Controller
$periodValidator = new PeriodValidator();
- $currentPeriod = Piwik::getPeriod();
+ $currentPeriod = Common::getRequestVar('period');
$availablePeriods = $periodValidator->getPeriodsAllowedForUI();
if (! $periodValidator->isPeriodAllowedForUI($currentPeriod)) {
diff --git a/plugins/MultiSites/Controller.php b/plugins/MultiSites/Controller.php
index ae19acc3a1..86792958f6 100644
--- a/plugins/MultiSites/Controller.php
+++ b/plugins/MultiSites/Controller.php
@@ -74,8 +74,8 @@ class Controller extends \Piwik\Plugin\Controller
{
Piwik::checkUserHasSomeViewAccess();
- $date = Piwik::getDate('today');
- $period = Piwik::getPeriod('day');
+ $date = Common::getRequestVar('date', 'today');
+ $period = Common::getRequestVar('period', 'day');
$view = new View("@MultiSites/getSitesInfo");
diff --git a/plugins/VisitsSummary/Reports/Get.php b/plugins/VisitsSummary/Reports/Get.php
index 3c5f703ec1..8ffcac2d9f 100644
--- a/plugins/VisitsSummary/Reports/Get.php
+++ b/plugins/VisitsSummary/Reports/Get.php
@@ -49,7 +49,7 @@ class Get extends \Piwik\Plugin\Report
'max_actions'
);
- $period = Piwik::getPeriod('day');
+ $period = Common::getRequestVar('period', 'day');
if (SettingsPiwik::isUniqueVisitorsEnabled($period)) {
$this->metrics = array_merge(['nb_uniq_visitors'], $this->metrics);
}