Discovered a Bug in how WooCommerce loads files, registers hooks…
-
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 507What 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:
https://scottbryner.com/a-bug-in-woocommerce/Let me know if you have any questions.
Cheers!
Scott
- The topic ‘Discovered a Bug in how WooCommerce loads files, registers hooks…’ is closed to new replies.