I am trying to: Activate Toolset WooCommerce 2.7.7.
I've activated WP Full DEBUG to find the cause.
This is what I see :
[06-Jul-2018 22:38:13 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_price() on boolean in /srv/users/serverpilot/apps/siteweb/public/wp-content/plugins/woocommerce-views/Class_WooCommerce_Views.php:2900
Stack trace:
#0 /srv/users/serverpilot/apps/siteweb/public/wp-includes/class-wp-hook.php(286): Class_WooCommerce_Views->ajax_process_wc_views_batchprocessing(false)
#1 /srv/users/serverpilot/apps/siteweb/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
#2 /srv/users/serverpilot/apps/siteweb/public/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /srv/users/serverpilot/apps/siteweb/public/wp-admin/includes/plugin.php(586): do_action('activate_woocom...', false)
#4 /srv/users/serverpilot/apps/siteweb/public/wp-admin/plugins.php(43): activate_plugin('woocommerce-vie...', 'hidden link...', false)
#5 {main}
thrown in /srv/users/serverpilot/apps/siteweb/public/wp-content/plugins/woocommerce-views/Class_WooCommerce_Views.php on line 2900
This is the only report so far, and I cannot replicate this issue.
I see that you use several other plugins - did you confirm that this issue happens only with Toolset and the required AddOns + WooCommerce and a native WordPress theme?
The code in the file the error happens refers to the batch process in Toolset > WooCommerce Views > Static Product Fields for Parametric Searches, and I run that too.
I could not see any error.
Either I miss a crucial step, or the plugin is eventually corrupt or there is a conflict with another plugin.
Can you help me to replicate this?
Eventually a copy of the site helps.
But I feel this is related to some other Plugin or similar.
Thanks for the additional information. I've seen one other ticket in the past where a similar problem occurred on a site with a large database of products (33,000 products), and I suspect this is a similar issue. When you said that you can activate WC Views first, then activate WooCommerce, that sounds like what was experienced there as well. It happens because when you activate WC Views, it checks to see if WC is active. If so, it loops over all the products in the database and performs some actions. This is when the memory problem occurs. If WC is not active, then the loop over products never happens. Let me reach out to my 2nd tier support team for some additional information about this and see if it's okay to simply skip these actions by activating the plugins in the reverse order, or if there are other side effects that need to be managed.
Hi, I have some feedback from my 2nd tier team. Please try the following steps and let me know the results.
- Deactivate WooCommerce Views and keep WooCommerce active
- Edit the file wp-content/plugins/woocommerce-views/views-woocommerce.php
- Comment out line 49 like this:
//register_activation_hook( __FILE__, array( $Class_WooCommerce_Views, 'ajax_process_wc_views_batchprocessing' ) );
- Save the file and upload to your server
- Reactivate WooCommerce Views
Let me know if the memory error returns.
Hi,
I've tried your suggestion. I clocked it, and it took approx. 6 seconds to activate, which is "normal". Meanwhile, I was running a tail on debug.log, and no issue whatsoever.
So I guess it's this product checking which was killing the server.
This is our first client where we want to make use of WooCommerce Views, but I'd say most of our clients have hundreds or thousands of products, with a few or a lot of variations. So this client is not an exception for us, more like the norm.
Do you plan on making a fix in the next release, to prevent this performance issue in the next release?
And for now, can I keep it like this without adverse effects?
In any event, THANKS for working with me on figuring this out !
Okay thanks for the update. Let me explain what this code does and why. WooCommerce Views calculates some values, like the price of the product and the quantity in stock, and stores them in separate custom fields so Views has the ability to do things like sorting by price more efficiently. These values are periodically calculated using a backend process on a schedule you can define in Toolset > Settings. When this line of code is not commented out, the system tries to run those calculations immediately when you activate WooCommerce Views. In most of our Users' cases, this isn't a problem. However on larger sites with many thousands of products this process may take too long and times out or throws a memory error on some hosts based on several variables like PHP version, PHP configurations, and so on.
You can keep the commented code and apply the same comment to future projects if you experience memory errors while activating. The main thing you will notice is that the calculated WooCommerce Views fields are not set immediately when you activate WooCommerce Views, and will not be automatically calculated until the next wp cron run as scheduled in Toolset > Settings. You may not even notice this on the front-end of the site unless you use Sorting or filtering by price in a View. In those cases, the results may be incorrect until the cron process has run and calculated all those values.
Thank you for those tech explanations, this helps me better understand.
I'll document this internally, and I've now visited the Toolset >WooCommerce Views and saw the settings you mentioned.
Thanks!
Hi, just a quick update to let you know the permanent fix for this problem will be included in the upcoming WooCommerce Views release. We expect to have that ready this week. I'll let you know when that's ready to download.