derwentx
Forum Replies Created
-
Forum: Plugins
In reply to: [Category Order and Taxonomy Terms Order] Woocommerce product category sortSame problem here, can’t get sorting to work with WooCommerce.
Forum: Plugins
In reply to: [WooCommerce] Woocommerce causing huge CPU usage spike??After some further debugging I’ve made some observations:
WooCommerce queues all attachments to be re-generated when a user changes themes.
So that filter can’t stop the background process once it already started:if ( apply_filters( 'woocommerce_background_image_regeneration', true ) ) { // Actions to handle image generation when settings change. add_action( 'update_option_woocommerce_thumbnail_cropping', array( __CLASS__, 'maybe_regenerate_images_option_update' ), 10, 3 ); add_action( 'update_option_woocommerce_thumbnail_image_width', array( __CLASS__, 'maybe_regenerate_images_option_update' ), 10, 3 ); add_action( 'update_option_woocommerce_single_image_width', array( __CLASS__, 'maybe_regenerate_images_option_update' ), 10, 3 ); add_action( 'after_switch_theme', array( __CLASS__, 'maybe_regenerate_image_theme_switch' ) ); }But the batch is stored in the options table!
public function delete_all_batches() { global $wpdb; $table = $wpdb->options; $column = 'option_name'; if ( is_multisite() ) { $table = $wpdb->sitemeta; $column = 'meta_key'; } $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; $wpdb->query( $wpdb->prepare( "DELETE FROM {$table} WHERE {$column} LIKE %s", $key ) ); // @codingStandardsIgnoreLine. return $this; } /** * Kill process. * * Stop processing queue items, clear cronjob and delete all batches. */ public function kill_process() { if ( ! $this->is_queue_empty() ) { $this->delete_all_batches(); wp_clear_scheduled_hook( $this->cron_hook_identifier ); } }So all you need to do is
– Back up your database
– SELECT FROM <your options table> WHEREoption_nameLIKE “%_batch_%”
– Delete the option with the value that looks likea:4757:{i:11165;a:1:{s:13:"attachment_id";s:5:"12976";} ...
– (optionally) use a plugin like wp-control to delete the cron job that looks likewp_1_wc_regenerate_images_cron_intervaland it will stop the updates
- This reply was modified 8 years, 4 months ago by derwentx.
Forum: Plugins
In reply to: [WooCommerce] Woocommerce causing huge CPU usage spike??Hi all,
I’m having the exact same issue. Unfortunately WordPress keeps DDoSing itself even after I add the filter:add_filter( 'woocommerce_background_image_regeneration', '__return_false' );to my theme’sfunctions.php.
It seemed to slow down somewhat but I’m still getting constant requests to"POST /wp-admin/admin-ajax.php?action=wp_1_wc_regenerate_images&nonce=d9e36adeef HTTP/1.1" 200 - "<my domain>/wp-admin/admin-ajax.php?action=wp_1_wc_regenerate_images&nonce=d9e36adeef" "WordPress/4.8.5;"from the hosts’ IP.
This results in huge memory usage which eventually takes the site down.Thanks for the commit! I’ll be in touch if I spot any more improvements! 😀
I’ve donated €10 and I’d be happy to submit the changes I made to the code, these include a filter at admin_init that removes extraneous columns from acui_columns:
add_action('admin_init', 'modify_user_edit_admin' ); function modify_user_edit_admin(){ global $pagenow; if(in_array($pagenow, array("user-edit.php", "profile.php"))){ $acui_columns = get_option("acui_columns"); // error_log("acui_columns: ".serialize($acui_columns)); if(is_array($acui_columns) && !empty($acui_columns)){ $new_columns = array(); $core_fields = array( 'username', 'user_email', 'first_name', 'role', 'last_name', 'nickname', 'display_name', 'description', 'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_postcode', 'billing_country', 'billing_state', 'billing_phone', 'billing_email', 'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_postcode', 'shipping_country', 'shipping_state' ); foreach ($acui_columns as $key => $column) { if(in_array($column, $core_fields)) { // error_log('removing column because core '.$column); continue; } if(in_array($column, $new_columns)) { // error_log('removing column because not unique '.$column); continue; } array_push($new_columns, $column); } update_option("acui_columns", $new_columns); }and changing the array check (the first if statement in acui_extra_user_profile_fields() to
if(is_array($headers) && !empty($headers)):Thanks