wpsharks / comet-cache

An advanced WordPress® caching plugin inspired by simplicity.
https://cometcache.com
GNU General Public License v3.0
77 stars 18 forks source link

Notice: id was called incorrectly. Product properties should not be accessed directly. #896

Open vestaxpdx opened 7 years ago

vestaxpdx commented 7 years ago

Hi

I have found a notice that is appearing after checkout is complete. When using Comet Cache Pro and Woocommerce

Notice: id was called incorrectly. Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), wp, WP->main, do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WC_Gateway_PPEC_Checkout_Handler->maybe_return_from_paypal, WC_Gateway_PPEC_Checkout_Handler->do_payment, WC_Gateway_PPEC_Checkout_Handler->handle_payment_response, WC_Order->payment_complete, do_action('woocommerce_payment_complete'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, wc_maybe_reduce_stock_levels, wc_reduce_stock_levels, wc_update_product_stock, do_action('woocommerce_product_set_stock'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WebSharks\CometCache\Pro\Classes\Plugin->autoClearPostCacheOnWooCommerceSetStock, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0 in MYSITE_URL/wp-includes/functions.php on line 4138

From digging you need to now call $product->id as $product->get_id()

This is being called in the function autoClearPostCacheOnWooCommerceSetStock($product) in the file: WP Plugins\comet-cache-pro\src\includes\traits\Plugin\WcpWooCommerceUtils.php

$counter += $this->autoClearPostCache($product->id);

Should be

$counter += $this->autoClearPostCache($product->get_id());

Do you guys support pull requests?

raamdev commented 7 years ago

Thanks so much for the report! This does sound like something that needs to be updated.

Do you guys support pull requests?

Yes! 😄 If you'd like to submit a PR we'd be happy to include it in the next release. :-) Either way, we'll get this fixed for the next release, but I'd love for you to get the props!

Please submit the PR to the Comet Cache Pro repo, as we build the Lite version from the Pro repo, so the PR needs to go there.

vestaxpdx commented 7 years ago

Cool will do! This is fixed here: https://github.com/websharks/comet-cache-pro/pull/318

raamdev commented 7 years ago

@vestaxpdx Thanks so much for the PR! I have merged this into the dev branch and this will go out with the next release. :-)

vestaxpdx commented 7 years ago

Awesome, cheers!