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() #14182

Closed
Findus23 opened this issue Mar 11, 2019 · 2 comments
Closed

Invalid argument supplied for foreach() #14182

Findus23 opened this issue Mar 11, 2019 · 2 comments
Assignees
Labels
answered For when a question was asked and we referred to forum or answered it.
Milestone

Comments

@Findus23
Copy link
Member

I have been seeing this error in sentry and nobody seems to have reported it before
It happens every Monday when the weekly email report is sent and doesn't seem to break anything obvious.

ErrorException: Invalid argument supplied for foreach()
#23 matomo/plugins/ScheduledReports/API.php(712): handleError
#22 matomo/plugins/ScheduledReports/API.php(712): validateReportParameters
#21 matomo/plugins/ScheduledReports/API.php(348): generateReport
#20 matomo/plugins/ScheduledReports/API.php(599): Piwik\Plugins\ScheduledReports\{closure}
#19 matomo/core/Context.php(75): changeIdSite
#18 matomo/plugins/ScheduledReports/API.php(668): sendReport
#17 matomo/plugins/ScheduledReports/API.php(0): call_user_func
#16 matomo/core/Scheduler/Scheduler.php(246): executeTask
#15 matomo/core/Scheduler/Scheduler.php(136): run
#14 matomo/plugins/CoreAdminHome/API.php(66): runScheduledTasks
#13 matomo/core/CronArchive.php(612): runScheduledTasks
#12 matomo/core/CronArchive.php(317): Piwik\{closure}
#11 matomo/core/Access.php(628): doAsSuperUser
#10 matomo/core/CronArchive.php(319): main
#9 matomo/plugins/CoreConsole/Commands/CoreArchiver.php(27): execute
#8 matomo/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): run
#7 matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(874): doRunCommand
#6 matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(195): doRun
#5 matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(0): call_user_func
#4 matomo/core/Console.php(98): Piwik\{closure}
#3 matomo/core/Access.php(628): doAsSuperUser
#2 matomo/core/Console.php(99): doRun
#1 matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(126): run
#0 matomo/console(27): null

According to sentry in this foreach

// unset invalid parameters
$availableParameterKeys = array_keys($availableParameters);
foreach ($parameters as $key => $value) {
if (!in_array($key, $availableParameterKeys)) {
unset($parameters[$key]);
}
}

$parameters is null

This function is called from

self::validateReportParameters($reportType, empty($parameters) ? $report['parameters'] : $parameters),

with the following variables set:

   
date 2019-03-04
idReport 4
language en
outputType 2
period week

Of course one could simply add a not null check, but I want to make sure there is no larger underlying error.

@Findus23 Findus23 added the Bug For errors / faults / flaws / inconsistencies etc. label Mar 11, 2019
@tsteur tsteur added this to the 3.10.0 milestone Mar 11, 2019
@sgiehl sgiehl self-assigned this Mar 18, 2019
@sgiehl
Copy link
Member

sgiehl commented Mar 18, 2019

@Findus23 could you check if the report that is sent does have any parameters set in the database?

@Findus23
Copy link
Member Author

@sgiehl You are right. It seems like something went wrong a long time ago:

+------------+----------+---------+---------------+-------------+----------+--------+--------+----------+-----------+--------------+---------------------+---------------------+-----------+---------------------------------+----------------------------+
|   idreport |   idsite | login   | description   |   idsegment | period   |   hour | type   | format   | reports   | parameters   | ts_created          | ts_last_sent        |   deleted |   evolution_graph_within_period |   evolution_graph_period_n |
|------------+----------+---------+---------------+-------------+----------+--------+--------+----------+-----------+--------------+---------------------+---------------------+-----------+---------------------------------+----------------------------|
|          4 |        2 | Lukas   | alle          |      <null> | week     |      4 | email  | html     | Array     | Array        | 2016-08-11 12:32:08 | 2016-09-26 07:00:50 |         0 |                               0 |                     <null> |
+------------+----------+---------+---------------+-------------+----------+--------+--------+----------+-----------+--------------+---------------------+---------------------+-----------+---------------------------------+----------------------------+

@Findus23 Findus23 added answered For when a question was asked and we referred to forum or answered it. and removed Bug For errors / faults / flaws / inconsistencies etc. labels Mar 19, 2019
@mattab mattab modified the milestones: 3.11.0, 3.10.0 May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

4 participants