From 900d202ad38f66dda940e57839546d5c912a5d5f Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Thu, 12 Aug 2021 10:36:54 +1200 Subject: [PATCH] Only set requests in tracking request set when correct value is given refs https://github.com/matomo-org/plugin-QueuedTracking/issues/153#issuecomment-896856651 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 --- core/Tracker/RequestSet.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/Tracker/RequestSet.php b/core/Tracker/RequestSet.php index cabcd56d496..d243f45504d 100644 --- a/core/Tracker/RequestSet.php +++ b/core/Tracker/RequestSet.php @@ -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;