Support » Plugin: Jetpack by » E_WARNING: Invalid argument supplied for foreach()

  • Resolved frisco


    Hi there…first, thanks for updating & supporting a great plugin.

    We use New Relic to monitor sites on our multi-site network, and one site is showing an E_WARNING that appears to be tied to Widget Visibility under Jetpack. Here’s the stack trace:

    Error message
    E_WARNING: Invalid argument supplied for foreach()

    Stack trace
    widget-conditions.php (249)
    in Jetpack_Widget_Conditions::sidebars_widgets called at ? (?)
    in call_user_func_array called at /srv/www/wordpress/wp-includes/plugin.php (199)
    in apply_filters called at /srv/www/wordpress/wp-includes/widgets.php (1016)
    in wp_get_sidebars_widgets called at /srv/www/wordpress/wp-includes/widgets.php (977)
    …alled at /srv/www/wordpress/wp-content/themes/genesis/lib/structure/
    footer.php (40)
    in genesis_footer_widget_areas called at ? (?)
    in call_user_func_array called at /srv/www/wordpress/wp-includes/plugin.php (429)
    in do_action called at /srv/www/wordpress/wp-content/themes/genesis/footer.php (17)
    in require_once called at /srv/www/wordpress/wp-includes/template.php (441)
    in load_template called at /srv/www/wordpress/wp-includes/template.php (417)
    … locate_template called at /srv/www/wordpress/wp-includes/
    general-template.php (65)
    …ooter called at /srv/www/wordpress/wp-content/themes/genesis/lib/
    framework.php (51)
    in genesis called at /srv/www/wordpress/wp-content/themes/genesis/page.php (15)
    in include called at /srv/www/wordpress/wp-includes/template-loader.php (74)
    in require_once called at /srv/www/wordpress/wp-blog-header.php (16)
    in require called at /srv/www/wordpress/index.php (17)

    It seems to occur when running post.php with action=edit but it might occur at other times.

    Let me know if I can provide more info to help you track down what’s going on.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Ben Lobaugh (blobaugh)


    Hi @frisco- Hmm, this is odd. That method should not be firing on the post.php page. I tested on my multisite and it acts as expected. Are you running any plugins that alter the way widgets work? What plugins are running on that subsite? Is New Relic moving through wp-admin to get that warning or does it only hit the public facing pages?

    Hi Ben. Thanks for the reply. Yes, to other widget-altering plugins, specifically I can’t (shouldn’t) opine on the wisdom of doing that; it was something the client chose to do.

    I think NR is working through anything PHP-related, including /wp-admin/ and public facing stuff. We only exclude cron from NR. The info I posted above was from post.php with the action=edit, but I just checked now and see the error on a public-facing category archive.

    As for other plugins, here is the list:

    Add Link to Facebook
    CMS Page Order
    Genesis Simple Edits
    Genesis Single Post Navigation
    Genesis Title Toggle
    Google Analytics for WordPress
    Google XML Sitemaps
    Gravity Forms PayPal Add-On
    Gravity Forms
    Jetpack by
    Manual Control for Jetpack
    Q and A
    Share Buttons by AddToAny
    Shiba Widgets
    WordPress SEO

    All except Shiba Widgets are repo plugins. If you aren’t seeing this error with widget visibility, then I suspect the answer might lie in the Shiba Widgets plugin. I can try to create a subsite and use widget visibility w/o Shiba Widgets and see if that changes things. If I find something, I’ll post back.

    Thanks in advance for any recommendations or pointers.

    Plugin Contributor Ben Lobaugh (blobaugh)


    There is a warning of a needed update on that page. It is older, but if this is a preexisting site maybe it needs updated?

    I will look through the code and see if I can see anything

    No, it’s running the latest version.

    We posted this comment,, regarding an unrelated issue tied to domain mapping, but that’s all we saw.

    TIA for taking a look. We’ll set up another test later tonight and see if it can be isolated more.

    Plugin Contributor Ben Lobaugh (blobaugh)


    I was able to recreate this issue by simply creating a new widget set. Looking further

    Plugin Contributor Ben Lobaugh (blobaugh)


    Looks like this Shiba Widgets plugin destroys the built in WordPress widgets.

    If you alter the Shiba Widgets file shiba-widgets.php near line 339 you will find:

    add_filter('sidebars_widgets', array($this,'sidebars_widgets'));

    Add a high number priority (default is 10) such as:

    add_filter('sidebars_widgets', array($this,'sidebars_widgets'), 99);

    It puts the filter later in the execution stack. It will allow all the normal WordPress (and Jetpack) widget stuff to be processed before Shiba Widgets destroys it and takes over the widget process.

    Let me know how that works for you.

    Thanks for going out of your way with an amazing and fast solution. Go Jetpack! We’ll give it a shot and let you know. If it works, we’ll be sure to let the plugin author know as well.

    Ben – We patched the Shiba plugin per your recommendation, and after more than an hour of traffic to the home page, single posts, pages, and category archives, NR didn’t record an error, so we’ll record this as a “Great job, Ben”. We flagged the plugin author to this thread so others can benefit.

    Thanks again.

    Plugin Contributor Ben Lobaugh (blobaugh)


    Awesome! Glad it worked out for you 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘E_WARNING: Invalid argument supplied for foreach()’ is closed to new replies.