WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] [closed] E_WARNING: Invalid argument supplied for foreach() (10 posts)

  1. frisco
    Member
    Posted 6 months ago #

    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
    …ess/wp-content/plugins/jetpack/modules/widget-visibility/
    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.

    http://wordpress.org/plugins/jetpack/

  2. Ben Lobaugh (blobaugh)
    Jetpack Engineer
    Plugin Author

    Posted 5 months ago #

    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?

  3. frisco
    Member
    Posted 5 months ago #

    Hi Ben. Thanks for the reply. Yes, to other widget-altering plugins, specifically http://shibashake.com/wordpress-theme/wordpress-custom-widgets-plugin. 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
    Akismet
    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 WordPress.com
    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.

  4. Ben Lobaugh (blobaugh)
    Jetpack Engineer
    Plugin Author

    Posted 5 months ago #

    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

  5. frisco
    Member
    Posted 5 months ago #

    No, it's running the latest version.

    We posted this comment, http://shibashake.com/wordpress-theme/wordpress-custom-widgets-plugin/comment-page-2#comment-94497, 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.

  6. Ben Lobaugh (blobaugh)
    Jetpack Engineer
    Plugin Author

    Posted 5 months ago #

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

  7. Ben Lobaugh (blobaugh)
    Jetpack Engineer
    Plugin Author

    Posted 5 months ago #

    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.

  8. frisco
    Member
    Posted 5 months ago #

    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.

  9. frisco
    Member
    Posted 5 months ago #

    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.

  10. Ben Lobaugh (blobaugh)
    Jetpack Engineer
    Plugin Author

    Posted 5 months ago #

    Awesome! Glad it worked out for you :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.