Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Same problem here, can’t get sorting to work with WooCommerce.

    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> WHERE option_name LIKE “%_batch_%”
    – Delete the option with the value that looks like a: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 like wp_1_wc_regenerate_images_cron_interval

    and it will stop the updates

    • This reply was modified 8 years, 4 months ago by derwentx.

    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’s functions.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.

    Thread Starter derwentx

    (@derwentx)

    Thanks for the commit! I’ll be in touch if I spot any more improvements! 😀

    Thread Starter derwentx

    (@derwentx)

    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

Viewing 5 replies - 1 through 5 (of 5 total)