Skip to content

Commit

Permalink
Only set requests in tracking request set when correct value is given
Browse files Browse the repository at this point in the history
refs matomo-org/plugin-QueuedTracking#153 (comment)

Possible warning:

>  /usr/share/piwik/core/Tracker/RequestSet.php(36): Warning - Invalid argument supplied for foreach() -

Not sure how this would happen and it might hide an actual error maybe. I've been looking through code for a while and couldn't really see where this might happen.  The only one I could find was bulk tracking a wrong JSON being set. Maybe we should throw an invalid tracking parameter exception when `requests` is not an array? https://github.com/matomo-org/matomo/blob/4.4.1/plugins/BulkTracking/Tracker/Requests.php#L78
  • Loading branch information
tsteur authored Aug 11, 2021
1 parent 99136cb commit 900d202
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/Tracker/RequestSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function setRequests($requests)
{
$this->requests = array();

if (empty($requests)|| !is_array($requests)) {
return;
}

foreach ($requests as $request) {
if (empty($request) && !is_array($request)) {
continue;
Expand Down

0 comments on commit 900d202

Please sign in to comment.