• Resolved midwestE

    (@edouble74)


    In woocommerce, when an attribute term is deleted, SG cache still has the product attribute terms cached and causes a fatal error on a product that has the deleted term until the SG cache is fully flushed. There should be a hook added to this plugin that clears the SG cache when an attribute is deleted.

    To reproduce:

    • Create an attribute taxonomy then term under /wp-admin/edit.php?post_type=product&page=product_attributes
    • Add this attribute term to a product
    • Delete the term
    • Refresh the product page

    Leads to fatal error until both memcache and supercacher cache is cleared

    <b>Fatal error</b>: Uncaught TypeError: ltrim(): Argument #1 ($string) must be of type string, WP_Error given in /home/customer/www/www.example.com/wp-includes/formatting.php:4379

    Fix is:

    add_action(‘deleted_term_taxonomy’,function ($id)
    {
        if (function_exists(‘sg_cachepress_purge_everything’) === true) {
            sg_cachepress_purge_everything();
        }
    });

    • This topic was modified 1 year, 10 months ago by midwestE.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Tsvetan Mitev

    (@tsvetanm)

    Hello @edouble74,

    I was not able to replicate the issue on a test WordPress instance.

    Please make sure that the “Automatic Purge” option in SiteGround Optimizer is enabled:
    https://www.siteground.com/tutorials/wordpress/sg-optimizer/supercacher/#Automatic_Purge
    and that you update the product from the Publish section once you modify the product attribute term. This should allow the smart purge feature to clear the cache for this particular product and refresh the product data.

    As for the suggested attribute hook. I have already forwarded your suggestion to our developers. If they decide to implement this particular feature in the future, we will make sure to include it in the plugin’s changelog.

    If you are still experiencing issues with managing any of the product attribute terms and you are a SiteGround customer, my recommendation is to submit a support request from your Client Area, and we will further look into this in more details.
    https://www.siteground.com/tutorials/getting-started/getting-help-from-our-support-team/

    Best Regards,
    Tsvetan Mitev

    Thread Starter midwestE

    (@edouble74)

    Just to be clear, you need to delete the top level (global) product attribute term before removing it from the product. Not the attribute from the product.

    I believe you misunderstood where the term needs to be removed because you mention “This should allow the smart purge feature to clear the cache for this particular product and refresh the product data.”

    That’s the issue, the product is not edited. The attribute term that the product already has is deleted without the product being edited.

    Plugin Support Tsvetan Mitev

    (@tsvetanm)

    I tested both scenarios, but I didn’t manage to replicate the fatal error on my end. The error appears to be specific to the setup of your website.

    Have in mind that deleting an attribute term globally will not trigger the cache purging functions in SiteGround Optimizer. In order to update the data you will need to purge the cache manually or use the hook provided in your initial reply.

    With that said, I’ve already forwarded your feedback to our developers. If they decide to implement this function in one of the upcoming versions we will include this information in the plugin’s changelog.

    Best Regards,
    Tsvetan Mitev




Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fatal error after deleting Woo attribute term’ is closed to new replies.