Skip Navigation

[Resolved] Can’t activate Toolset WooCommerce, PHP FATAL Error

This thread is resolved. Here is a description of the problem and solution.

Problem: When I activate WooCommerce Views I experience a PHP Fatal Error after waiting a long time to activate.

Solution: This seems to happen from time to time when a site has a large number of Products before activating WooCommerce Views. WC Views tries to calculate some values for all posts when you activate it, which can lead to timeout issues on some sites. You can comment out the activation hook responsible for this process to activate WC Views, then eventually the normal cron process will run to perform these calculations.

Comment this line in /wp-content/plugins/woocommerce-views/views-woocommerce.php (currently line 49):

//register_activation_hook( __FILE__, array( $Class_WooCommerce_Views, 'ajax_process_wc_views_batchprocessing' ) );
This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 2.37 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 7 replies, has 3 voices.

Last updated by Christian Cox 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#921883

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

#921960

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.

#922201

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.

#922548

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.

#922554

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 !

#922653

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.

#922659

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!

#1198852

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.