Support » Plugin: Media Cleaner - Clean & Optimize Space » Woocommerce support

  • Resolved simplysellingstuff

    (@simplysellingstuff)


    The free version is picking up all my woocommerce gallery images as unused. The product image it sees as used but lists all gallery images as unused. Does the pro version have woocommcerce support or am I just doing some thing wrong?

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter simplysellingstuff

    (@simplysellingstuff)

    Well looks like I spoke too soon.

    I have been using the plugin without the “post meta” scanning enabled. I have now discovered that woo commerce stores the featured product image in the wp_postmeta table. Without “post meta” checked it looks like it is marking featured product images as unused.

    I assume the plugin would work if I could use post meta scanning. However when I check the post meta scanning option my server pegs out 6 cores during the preparing post segment of the scan. The server prepares 200 posts in one minute. Since I have over 6000 posts the browser times out before the posts are even prepared.

    I have disabled every single plugin including woo commerce and replicate the same issue of profoundly slow post preparation.

    All this said I think I have found the problem. My postmeta table is very large by wordpress standards. It is now pushing 30 megs and growing. I very much doubt most users of media cleaner will be bringing post meta tables of this size. So I don’t consider this a flaw of the plugin. Ran against a more typical .5-2mb post_meta table I do not think these queries would not be an issue at all.

    So here’s an idea. Perhaps add another check box option to more specifically search post meta for wordpress featured images as opposed to searching ALL the entire post_meta table for any reference to the post in question? This would make media cleaner usable on very large systems.

    SELECT * FROM wordpress.wp_postmeta where meta_key = “_thumbnail_id”;

    Regarding debug. Are you referring to the log file option? I do have that checked. I have no php log file errors either.

    Plugin Author Jordy Meow

    (@tigroumeow)

    So here’s an idea. Perhaps add another check box option to more specifically search post meta for wordpress featured images as opposed to searching ALL the entire post_meta table for any reference to the post in question? This would make media cleaner usable on very large systems.

    The plugin has already too many options and adding little options like this to avoid “checks” will make it more and more complicated 🙁 I prefer to find a way to fix this.

    SELECT * FROM wordpress.wp_postmeta where meta_key = “_thumbnail_id”

    ;

    Actually I was doing this before but you can still do this manually if you really wish 🙂

    The plugin only checks the postmeta for each post (when analyzing each post), so actually it’s already quite limited and normally wouldn’t break. What you could try to change is the number of posts analyzed at the same time (by default it’s 5).

    my server pegs out 6 cores during the preparing post segment of the scan

    What do you actually mean by that? 🙂

    Thread Starter simplysellingstuff

    (@simplysellingstuff)

    The plugin has already too many options and adding little options like this to avoid “checks” will make it more and more complicated 🙁 I prefer to find a way to fix this.

    Agreed. Cluttered UIs are bad.

    The plugin only checks the postmeta for each post (when analyzing each post), so actually it’s already quite limited and normally wouldn’t break. What you could try to change is the number of posts analyzed at the same time (by default it’s 5).

    Tried raising to 20 50 and 100. Same performance issue with post meta.

    my server pegs out 6 cores during the preparing post segment of the scan

    I think most people using this plugin are on shared hosting. My point is when scanning post meta I have 6 dedicated 3ghz cores running 100% for 15+ minutes. That’s not an intensive query, that’s an unusable one.

    All this said I finally gave up and looked at the plugin.

    Current code from core.php lines 612 to 613

    $res = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $post
    AND meta_key = '_product_image_gallery'" );

    Modified lines 612 to 614

    $res = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE (post_id = $post
    AND meta_key = '_product_image_gallery') or (post_id = $post AND meta_key = '_thumbnail_id')" );

    The addition of the check against _thumbnail_id is now marking my woo commerce featured product images as used. Tested on dev server I saw no measurable performance difference after modifying this query. However now my featured product images are no longer being removed.

    Please update me if you decide to add this to your production stream. Otherwise I can simply continue using the current version with my mod and forgo updates until they prove unavoidable.

    Plugin Author Jordy Meow

    (@tigroumeow)

    Hi @simplysellingstuff,

    Yes, that’s a way to do it in your case, avoiding checking the Meta by the options and checking the only meta you are using by adding in this request.

    However, if I add it, then the plugin does something is not supposed to check in some case and a redundant case in others. So basically it’s not good for me to add it.

    If you look at the line 478-481:

    $metas = $wpdb->get_col( $wpdb->prepare( “SELECT meta_value FROM $wpdb->postmeta
    WHERE post_id = %d
    AND meta_key = ‘_thumbnail_id’ $like”, $post )
    );

    So basically, it is doing almost only this, checking the _thumbnail_id and performing also two LIKE. The only issue I see performance-wise in your case is the two LIKE, since the thumbnail_id causes no troubles in your previous modification.

    What about rolling back to my version of the plugin, and simplifying the post_meta detection? You can actually do that easily by going at the top of the core.php, and by modifying $metakeys 🙂 Just make it into an empty array. If that fixes it for you, and maybe for others, then definitely I could add an option with the additional $metakeys (and actually I have added ‘%gallery%’ and ‘%ids%’ by safety only, to cover unknown cases).

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Woocommerce support’ is closed to new replies.