diff options
author | Stefan Giehl <stefan@matomo.org> | 2020-03-22 23:02:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 23:02:44 +0300 |
commit | a4e4f3d79114080609611c9182215c546539e3af (patch) | |
tree | f33c2989d2bee90fc61b0d84451748fd70c89cd8 /core/CronArchive.php | |
parent | 8b9a214f640ba7df76d6c964f8bc70b39ff00e7a (diff) |
Remove PHP serialization response format (#15558)
Diffstat (limited to 'core/CronArchive.php')
-rw-r--r-- | core/CronArchive.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php index bb1337dbb0..01051cd923 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -831,7 +831,7 @@ class CronArchive */ private function getVisitsRequestUrl($idSite, $period, $date, $segment = false) { - $request = "?module=API&method=API.get&idSite=$idSite&period=$period&date=" . $date . "&format=php"; + $request = "?module=API&method=API.get&idSite=$idSite&period=$period&date=" . $date . "&format=json"; if ($segment) { $request .= '&segment=' . urlencode($segment); } @@ -913,7 +913,7 @@ class CronArchive $this->logArchiveWebsite($idSite, "day", $date); $content = $this->request($url); - $daysResponse = Common::safe_unserialize($content); + $daysResponse = json_decode($content, true); if (empty($content) || !is_array($daysResponse) @@ -925,7 +925,12 @@ class CronArchive $store->add($idSite); } - $this->logError("Empty or invalid response '$content' for website id $idSite, " . $timerWebsite->__toString() . ", skipping"); + if (empty($content)) { + $this->logError("Empty response for website id $idSite, " . $timerWebsite->__toString() . ", skipping"); + } else { + $this->logError("Invalid json response '$content' (" . json_last_error_msg() . ") for website id $idSite, " . $timerWebsite->__toString() . ", skipping"); + } + $this->skippedDayOnApiError++; $this->skipped++; return false; @@ -1180,7 +1185,7 @@ class CronArchive $success = $success && $this->checkResponse($content, $url); if ($noSegmentUrl == $url && $success) { - $stats = Common::safe_unserialize($content); + $stats = json_decode($content, true); if (!is_array($stats)) { $this->logError("Error unserializing the following response from $url: " . $content); @@ -1258,7 +1263,7 @@ class CronArchive } /** - * Issues a request to $url eg. "?module=API&method=API.getDefaultMetricTranslations&format=original&serialize=1" + * Issues a request to $url eg. "?module=API&method=API.getDefaultMetricTranslations&format=json" * * @param string $url * @return string |