• Resolved Preliot

    (@preliot)


    Issue

    I’ve tried to upgrade my website to PHP 7.2, but got allot of warnings wit ‘Invalid argument supplied for foreach()’. This happens in several classes, as seen in my Logs:

    [28-Feb-2019 07:58:02 UTC] PHP   1. {main}() \path\to\project\wp-admin\index.php:0
    [28-Feb-2019 07:58:02 UTC] PHP   2. require_once() \path\to\project\wp-admin\index.php:10
    [28-Feb-2019 07:58:02 UTC] PHP   3. do_action() \path\to\project\wp-admin\admin.php:253
    [28-Feb-2019 07:58:02 UTC] PHP   4. WP_Hook->do_action() \path\to\project\wp-includes\plugin.php:465
    [28-Feb-2019 07:58:02 UTC] PHP   5. WP_Hook->apply_filters() \path\to\project\wp-includes\class-wp-hook.php:310
    [28-Feb-2019 07:58:02 UTC] PHP   6. WP_Piwik\Admin\Statistics->show() \path\to\project\wp-includes\class-wp-hook.php:286
    [28-Feb-2019 07:58:02 UTC] PHP   7. do_meta_boxes() \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Admin\Statistics.php:31
    [28-Feb-2019 07:58:02 UTC] PHP   8. WP_Piwik\Widget\Pages->show() \path\to\project\wp-admin\includes\template.php:1306
    [28-Feb-2019 07:58:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Widget.php on line 109
    [28-Feb-2019 07:58:02 UTC] PHP Stack trace:
    [28-Feb-2019 07:58:02 UTC] PHP   1. {main}() \path\to\project\wp-admin\index.php:0
    [28-Feb-2019 07:58:02 UTC] PHP   2. require_once() \path\to\project\wp-admin\index.php:10
    [28-Feb-2019 07:58:02 UTC] PHP   3. do_action() \path\to\project\wp-admin\admin.php:253
    [28-Feb-2019 07:58:02 UTC] PHP   4. WP_Hook->do_action() \path\to\project\wp-includes\plugin.php:465
    [28-Feb-2019 07:58:02 UTC] PHP   5. WP_Hook->apply_filters() \path\to\project\wp-includes\class-wp-hook.php:310
    [28-Feb-2019 07:58:02 UTC] PHP   6. WP_Piwik\Admin\Statistics->show() \path\to\project\wp-includes\class-wp-hook.php:286
    [28-Feb-2019 07:58:02 UTC] PHP   7. do_meta_boxes() \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Admin\Statistics.php:31
    [28-Feb-2019 07:58:02 UTC] PHP   8. WP_Piwik\Widget\Keywords->show() \path\to\project\wp-admin\includes\template.php:1306
    [28-Feb-2019 07:58:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Widget.php on line 109
    [28-Feb-2019 07:58:02 UTC] PHP Stack trace:
    [28-Feb-2019 07:58:02 UTC] PHP   1. {main}() \path\to\project\wp-admin\index.php:0
    [28-Feb-2019 07:58:02 UTC] PHP   2. require_once() \path\to\project\wp-admin\index.php:10
    [28-Feb-2019 07:58:02 UTC] PHP   3. do_action() \path\to\project\wp-admin\admin.php:253
    [28-Feb-2019 07:58:02 UTC] PHP   4. WP_Hook->do_action() \path\to\project\wp-includes\plugin.php:465
    [28-Feb-2019 07:58:02 UTC] PHP   5. WP_Hook->apply_filters() \path\to\project\wp-includes\class-wp-hook.php:310
    [28-Feb-2019 07:58:02 UTC] PHP   6. WP_Piwik\Admin\Statistics->show() \path\to\project\wp-includes\class-wp-hook.php:286
    [28-Feb-2019 07:58:02 UTC] PHP   7. do_meta_boxes() \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Admin\Statistics.php:31
    [28-Feb-2019 07:58:02 UTC] PHP   8. WP_Piwik\Widget\Referrers->show() \path\to\project\wp-admin\includes\template.php:1306
    [28-Feb-2019 07:58:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Widget\Plugins.php on line 28
    [28-Feb-2019 07:58:02 UTC] PHP Stack trace:
    [28-Feb-2019 07:58:02 UTC] PHP   1. {main}() \path\to\project\wp-admin\index.php:0
    [28-Feb-2019 07:58:02 UTC] PHP   2. require_once() \path\to\project\wp-admin\index.php:10
    [28-Feb-2019 07:58:02 UTC] PHP   3. do_action() \path\to\project\wp-admin\admin.php:253
    [28-Feb-2019 07:58:02 UTC] PHP   4. WP_Hook->do_action() \path\to\project\wp-includes\plugin.php:465
    [28-Feb-2019 07:58:02 UTC] PHP   5. WP_Hook->apply_filters() \path\to\project\wp-includes\class-wp-hook.php:310
    [28-Feb-2019 07:58:02 UTC] PHP   6. WP_Piwik\Admin\Statistics->show() \path\to\project\wp-includes\class-wp-hook.php:286
    [28-Feb-2019 07:58:02 UTC] PHP   7. do_meta_boxes() \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Admin\Statistics.php:31
    [28-Feb-2019 07:58:02 UTC] PHP   8. WP_Piwik\Widget\Plugins->show() \path\to\project\wp-admin\includes\template.php:1306
    [28-Feb-2019 07:58:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Widget\Search.php on line 28
    [28-Feb-2019 07:58:02 UTC] PHP Stack trace:
    [28-Feb-2019 07:58:02 UTC] PHP   1. {main}() \path\to\project\wp-admin\index.php:0
    [28-Feb-2019 07:58:02 UTC] PHP   2. require_once() \path\to\project\wp-admin\index.php:10
    [28-Feb-2019 07:58:02 UTC] PHP   3. do_action() \path\to\project\wp-admin\admin.php:253
    [28-Feb-2019 07:58:02 UTC] PHP   4. WP_Hook->do_action() \path\to\project\wp-includes\plugin.php:465
    [28-Feb-2019 07:58:02 UTC] PHP   5. WP_Hook->apply_filters() \path\to\project\wp-includes\class-wp-hook.php:310
    [28-Feb-2019 07:58:02 UTC] PHP   6. WP_Piwik\Admin\Statistics->show() \path\to\project\wp-includes\class-wp-hook.php:286
    [28-Feb-2019 07:58:02 UTC] PHP   7. do_meta_boxes() \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Admin\Statistics.php:31
    [28-Feb-2019 07:58:02 UTC] PHP   8. WP_Piwik\Widget\Search->show() \path\to\project\wp-admin\includes\template.php:1306
    [28-Feb-2019 07:58:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in \path\to\project\wp-content\plugins\wp-piwik\classes\WP_Piwik\Widget\Noresult.php on line 28
    

    (real path changed to \path\to\project)

    Current config

    PHP 7.0.x
    Wordpress 5.1
    WP_Piwik 1.0.19

Viewing 7 replies - 1 through 7 (of 7 total)
  • I am seeing the same too. A lot of my clients use this plugin and anyone on PHP 7.2 has this issue. PHP 7.1 appears to not have this issue.

    This is from my cPanel php error log:

    [01-Mar-2019 03:35:04 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Visitors.php on line 38
    [01-Mar-2019 03:35:04 UTC] PHP Warning:  array_reverse() expects parameter 1 to be array, null given in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Visitors.php on line 61
    [01-Mar-2019 03:35:04 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Browsers.php on line 46
    [01-Mar-2019 03:35:04 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/BrowserDetails.php on line 46
    [01-Mar-2019 03:35:05 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Screens.php on line 44
    [01-Mar-2019 03:35:05 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Systems.php on line 42
    [01-Mar-2019 03:35:05 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/SystemDetails.php on line 42
    [01-Mar-2019 03:35:05 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Country.php on line 46
    [01-Mar-2019 03:35:06 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 03:35:06 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 03:35:06 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 03:35:06 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Plugins.php on line 28
    [01-Mar-2019 03:35:07 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Search.php on line 28
    [01-Mar-2019 03:35:07 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Noresult.php on line 28
    Plugin Author braekling

    (@braekling)

    Did you check your statistics page? Do all measurements appear as expected? In this case, you can ignore the warnings for now. I will add some validity checks with the next update there.

    Or aren’t the statistics shown anymore? In this case, can you please provide the test script result (WP-Matomo settings -> support tab -> run test script)? Maybe this will give a hint, why WP-Matomo does not connect on PHP 7.2.

    Oh, and on which pages do the warnings appear? If you open the stats, only, or everywhere on your blog?

    @braekling If I check Matomo it shows up something, but I have no idea if it shows up the correct amount.

    If I go DASHBOARD > WP-Piwik = It shows up with “Piwik error: The parameter ‘idSite=’ is missing from the request.”

    If I go SETTINGS > WP-Piwik = It says “WP-Piwik 1.0.19 is successfully connected to Piwik 3.8.1. You are running WordPress 5.1.”

    I think I may have fixed it but. With the settings I’ve just gone over and applied everything again. Sometimes changing a value here or there on the page and then saving. Now the DASHBOARD > WP-Piwik is showing up. Values are correct with Matomo direct login. But it has not been recording the last week or so. So something was up.

    I’m still on PHP v7.2 with this client.

    I don’t want to post the output of the test script here. But if you have a support email I can send it to you.

    [01-Mar-2019 04:10:01 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Visitors.php on line 38
    [01-Mar-2019 04:10:01 UTC] PHP Warning:  array_reverse() expects parameter 1 to be array, null given in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Visitors.php on line 61
    [01-Mar-2019 04:10:01 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Browsers.php on line 46
    [01-Mar-2019 04:10:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/BrowserDetails.php on line 46
    [01-Mar-2019 04:10:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Screens.php on line 44
    [01-Mar-2019 04:10:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Systems.php on line 42
    [01-Mar-2019 04:10:02 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/SystemDetails.php on line 42
    [01-Mar-2019 04:10:03 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Country.php on line 46
    [01-Mar-2019 04:10:03 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 04:10:03 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 04:10:03 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 04:10:04 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Plugins.php on line 28
    [01-Mar-2019 04:10:04 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Search.php on line 28
    [01-Mar-2019 04:10:04 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Noresult.php on line 28
    [01-Mar-2019 04:20:23 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Visitors.php on line 38
    [01-Mar-2019 04:20:23 UTC] PHP Warning:  array_reverse() expects parameter 1 to be array, null given in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Visitors.php on line 61
    [01-Mar-2019 04:20:24 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Browsers.php on line 46
    [01-Mar-2019 04:20:24 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/BrowserDetails.php on line 46
    [01-Mar-2019 04:20:24 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Screens.php on line 44
    [01-Mar-2019 04:20:24 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Systems.php on line 42
    [01-Mar-2019 04:20:25 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/SystemDetails.php on line 42
    [01-Mar-2019 04:20:25 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Country.php on line 46
    [01-Mar-2019 04:20:25 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 04:20:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 04:20:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget.php on line 109
    [01-Mar-2019 04:20:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Plugins.php on line 28
    [01-Mar-2019 04:20:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Search.php on line 28
    [01-Mar-2019 04:20:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /home/USERNAME/public_html/wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Noresult.php on line 28
    Plugin Author braekling

    (@braekling)

    Sounds like the site ID was not estimated correctly. I’m just wondering how this can be affected by an PHP update… on an existing setup, the site ID is stored in your database.

    I’ll try to understand what’s happening there. In the meanwhile, it may be a good idea to check if the estimated site ID in WP-Matomo is still showing up and correct after updating to PHP 7.2. If not, it may help to reset WP-Matomo’s settings and to reconfigure the plugin once.

    Happy to provide any logs, just will remove any identifiable points.

    Yeah it is weird. Because not every PHP v7.2 comes up with the error. It’s not a caching thing either. I’ve even removed the plugin completely and then re-installed it, remove the WP-Piwik cache, then reset it, configure it all back again. Just really strange.

    Plugin Author braekling

    (@braekling)

    I checked on several systems, PHP 7.2 should not make any problems.

    Just to be sure, I recommend to check the WP-Piwik settings after a PHP update: Is the site ID correct, does the connection still work? But currently, I don’t see a reason why an PHP update should break the setup.

    The warnings won’t appear anymore in 1.0.20, I added some checks for empty values.

    I will close this for now, if somebody else notices this issue, please tell me, so we can reopen it and maybe figure out what’s causing this.

    • This reply was modified 5 years, 8 months ago by braekling.
    Thread Starter Preliot

    (@preliot)

    Your extra checks revealed the issue: Now the message says something about a site id of zero.

    Quickfix: Save the settings of WP-Matamoto again by clicking the ‘Save’ button.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP 7.2 > Invalid argument supplied for foreach()’ is closed to new replies.