WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Discovered a Bug in how WooCommerce loads files, registers hooks... (8 posts)

  1. dyspersion media
    Member
    Posted 1 year ago #

    Hi guys!

    I have some info on a bug that others have reported but remains unresolved. I've seen other threads about this, but they've all been closed as resolved, so I'm opening a new thread since it's not resolved yet. I think it's a rare bug that only happens under certain circumstances, so that's probably why it hasn't come up more often.

    Basically, I'm seeing numerous warning messages concerning WooCommerce registering hooks without first defining valid callbacks.

    Sample Error message:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback,
    'wc_setup_product_data' was given in /wp-includes/plugin.php on line 507

    What it comes down to is the plugin is registering action hooks when it is initialized, but the definition for the callback functions is attached to the "init" action hook which doesn't fire until several action hooks after the theme loads. So, if a theme calls any of the hooked functions, such as the_post(), for example, between the time your plugin is initialized and the "init" hook, you get the above warnings.

    I suggest you move the definition of your callbacks ahead of the hook registrations.

    I posted a more complete breakdown of this problem and the issue on my personal blog here:
    http://scottbryner.com/a-bug-in-woocommerce/

    Let me know if you have any questions.

    Cheers!
    Scott

    https://wordpress.org/plugins/woocommerce/

  2. Daniel Espinoza
    Member
    Posted 1 year ago #

    Thanks for posting that Scott. This is a support forum, and a better place to post this would be in the issues tracker at GitHub. That way the developers can recreate it and work on it from there.

  3. groundfalling
    Member
    Posted 1 year ago #

    @dyspersion media
    on your site you have done the in-depth analysis of the problem causing these messages but you have not suggested any solution.
    I just updated my woocommerce plugin from 2.0 to 2.1 and im facing the similar issue.
    Could please add how to resolve this problem? Thanks

  4. groundfalling
    Member
    Posted 1 year ago #

    can anyone please tell me how to remove these two warnings, they seem to appear on both front and backend:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'wc_setup_product_data' was given in /home1/harris/public_html/mysite/wp-includes/plugin.php on line 507

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'woocommerce_reset_loop' was given in /home1/harris/public_html/mysite/wp-includes/plugin.php on line 507

    I have even tried to update to 2.1.3 through FTP since it wasnt allowing me to update from backend but still same issue, the warnings just wont go

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    @groundfalling: It is considered impolite to interrupt another poster's ongoing thread unless you are posting a solution or suggestion. As per the Forum Welcome, please post your own topic.

  6. dyspersion media
    Member
    Posted 1 year ago #

    @growdev - will do.

    @groundfalling -- I didn't post a solution because there isn't one. Woo needs to fix this in their plugin. There are some potential workarounds, but they would be individual/particular to each install and would have to be undone when Woo issues a fix.

    It's a nasty bug that cascades down and causes potentially major problems in certain cases. I feel your pain, though. ;)

  7. dyspersion media
    Member
    Posted 1 year ago #

    FYI - this issue is fixed as of v2.1.4.

  8. groundfalling
    Member
    Posted 1 year ago #

    @dyspersion
    thanks for the info but i think i will stick with 2.0
    had enough with 2.1

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic