Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid argument supplied for foreach() #10453

Closed
l36t opened this issue Aug 30, 2016 · 19 comments
Closed

Invalid argument supplied for foreach() #10453

l36t opened this issue Aug 30, 2016 · 19 comments
Labels
duplicate For issues that already existed in our issue tracker and were reported previously. Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users.

Comments

@l36t
Copy link

l36t commented Aug 30, 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
Copy link
Member

mattab commented Sep 27, 2016

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 mattab added the Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users. label Sep 27, 2016
@mattab mattab added this to the Mid term milestone Nov 11, 2016
@mattab
Copy link
Member

mattab commented Nov 11, 2016

@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
Copy link

pardvm commented Feb 21, 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
Copy link

wmtech-1 commented May 9, 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
Copy link
Member

sgiehl commented May 9, 2018

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
Copy link

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
Copy link

mrmason commented Dec 3, 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
Copy link

mrmason commented Dec 3, 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#0: *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
Copy link

wmtech-1 commented Dec 3, 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
Copy link

pardvm commented Dec 3, 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
Copy link
Member

tsteur commented Dec 3, 2019

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

@tsteur
Copy link
Member

tsteur commented Dec 3, 2019

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

@pardvm
Copy link

pardvm commented Dec 3, 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
Copy link

mrmason commented May 27, 2020

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

@tsteur
Copy link
Member

tsteur commented May 27, 2020

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
Copy link
Member

tsteur commented May 27, 2020

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

@mrmason
Copy link

mrmason commented Feb 3, 2022

FYI, upgrading to php 7.2 fixed this error entirely. Probably safe to close this issue as I can't imagine many people are still running php 7.1.

@blizzz
Copy link

blizzz commented Feb 3, 2022

I have it running on 7.2 and see it. Yet have pending Matomo updates.

@sgiehl
Copy link
Member

sgiehl commented Feb 4, 2022

this was fixed with #17877

@sgiehl sgiehl closed this as completed Feb 4, 2022
@justinvelluppillai justinvelluppillai added wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it. duplicate For issues that already existed in our issue tracker and were reported previously. and removed wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it. labels Feb 22, 2022
@innocraft-automation innocraft-automation removed this from the Backlog (Help wanted) milestone Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate For issues that already existed in our issue tracker and were reported previously. Waiting for user feedback Indicates the Matomo team is waiting for feedback from the author or other users.
Projects
None yet
Development

No branches or pull requests

10 participants