@l36t opened this Issue on August 30th 2016

my apache error.log sometimes print:
PHP Warning: Invalid argument supplied for foreach() in C:\phpEnv\Apache24\htdocs\piwik\core\Tracker\RequestSet.php on line 38

I use piwik 2.16.1,php5.5.36,how to resolve this problem,does this warning affect collecting data?

@mattab commented on September 27th 2016 Member

Thanks for the report @l36t - do you know how to reproduce this issue? if we can reproduce it we will be able to fix it. Thanks for sending more information....

for example maybe you could find the request from your webserver access log that triggered this error ?

@mattab commented on November 11th 2016 Member

@l36t please see previous comment, can you send the HTTP request in your access.log file, that has triggered this error? (you can find it by looking at the datetime of the error and finding back the request that was made at the same second or one-two seconds before)

@pardvm commented on February 21st 2017

Hi @mattab ,
I'm experiencing same problem: I get about 2500 php warnings:

grep "PHP Warning" error_log |wc -l
2482

like this one:

[Tue Feb 21 21:10:26.535362 2017] [php7:warn] [pid 16922:tid 140190181963520] [client 181.196.76.228:59504] PHP Warning: Invalid argument supplied for foreach() in /datos/httpd-pwk-2.4.25/htdocs/analytics/core/Tracker/RequestSet.php on line 38, referer: http://www.extra.ec/actualidad/elecciones2017-resultados-votaciones-actualidad-DD1104603

The requests "surrounding" that error are attached in the following file:
piwik.requests.txt

Please, let me know if you need more information: I'm wondering if this could imply to lost hits

Thank you in advance.

@wmtech-1 commented on May 9th 2018

I have the same problem with the same error message and use the most recent version 3.5.0. It may have something to do with log importing.

It looks like you need to make sure that $requests in line 38 is definitely an array before feeding the var to foreach().

[09-May-2018 17:39:49 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:39:57 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:40:03 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:40:10 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:40:17 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:40:32 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:40:46 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:41:01 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:41:01 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38 [09-May-2018 17:42:05 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/nginx/public/core/Tracker/RequestSet.php on line 38

@sgiehl commented on May 9th 2018 Member

Are you able to produce a stack trace for that error? would be good to know where the empty requestset comes from, as that might be the main problem

@wmtech-1 commented on May 10th 2018

Sorry, no. We cannot fiddle with the live installation and I it seems the error is not easy to reproduce in a test environment.

Maybe I can add a simple log to dump the var if the error happens ...

@mrmason commented on December 3rd 2019

We're seeing this error with the latest version using PHP 7.1, and we use redis.

grep 'RequestSet.php on line 38' error.log | wc -l
67760

That's almost 70k errors in less than 12 hours.

How can we diagnose what's going on here ?

@mrmason commented on December 3rd 2019

OK, disabling redis as the QueueTracker stops this problem,, but the load on the server goes mad.

If you enable MySQL queue then the error doesn't show.

If you enable Redis Queue then the error returns

2019/12/03 14:05:31 [error] 30283<a href='/0'>#0</a>: *129599 FastCGI sent in stderr: "PHP message: PHP Warning:  Invalid argument supplied for foreach() in core/Tracker/RequestSet.php on line 38" while reading upstream, client: 
@wmtech-1 commented on December 3rd 2019

I can confirm the same environment. PHP 7.1 and Redis and still lots of that error message with the most recent version.

@pardvm commented on December 3rd 2019

In my case, I lived together with that bunch of errors every day... until they disapeared suddenly.
Now I have v3.11 and the errors still away
I never was able to explain it nor reproduce in a lab environment

@tsteur commented on December 3rd 2019 Member

How are you tracking? Using the JavaScript tracker? We can't reproduce this issue here.

@tsteur commented on December 3rd 2019 Member

@wmtech-1 be good if you could update to latest version as well if not done yet.

@pardvm commented on December 3rd 2019

@tsteur,
I'm tracking with javascript tracker and, also, iOS and Android SDK
I've being using those trackers for years and it was only a period of time when the errors appeared, they stood there for months and, then, they disappeared (luckly)

@mrmason commented on May 27th 2020

We're still seeing these errors - using php 7.1.33 - maybe we need to update that ?

@tsteur commented on May 27th 2020 Member

Are you all using Queued tracking? I had a quick look in the code and right now I can't really think of a way this may be triggered.

@tsteur commented on May 27th 2020 Member

We could workaround and just add a check to avoid this notice. Chances are though it might actually maybe hide a bug.

Powered by GitHub Issue Mirror