• Resolved shaunek

    (@shaunek)


    I would like to suggest a set of patches for this plugin. I couldn’t find a Github repo associated to this plugin so I’m just providing a Github Gist with two patch files. If there is a better way to provide this feedback please let me know.

    https://gist.github.com/shaunek-hero/e58a67e977b136e3d2572ad1fc5cf63d

    Summary: This patch changes the plugin code to call $order->save_meta_data() instead of $order->save() wherever practical.

    Rationale:

    1. This could be considered a performance enhancement since calling save_meta_data() does a lot less work compared to save()
    2. Since these calls to save() seem to be targeted at saving order meta data only, it might be good to reduce the number of woocommerce hooks that get invoked as a result, which may cause fewer bugs in other plugins and themes.

    In my case, I found that the calls to?$order->save()?in this plugin were interacting with another of my plugins – my other plugin had a very poorly coded callback for the?woocommerce_after_order_object_save?hook, which, as the name implies, runs every time?$order->save()?is invoked. Since it is a private plugin I can’t share the actual code, but I’ll just say that the callback in my other plugin was doing some special inventory modifications in certain cases. I have observed a few cases where a brand new order was created (customer checked out) and at the same moment the?woocommerce-shipstation-integration?plugin’s export process ran and since the export calls?$order-save()?there was a race condition (due to my poorly coded plugin) and the special inventory modifications were performed twice. This is a relatively rare race condition, but I consider it a pretty serious bug in my plugin. Make no mistake, I fully understand that the bulk of the reason for the race condition was due to my poorly coded plugin, and I have made a substantial improvement to my plugin such that this race condition will be very unlikely in the future. However, I got to thinking that if the?woocommerce-shipstation-integration?plugin didn’t even call?$order->save()?my painful bug wouldn’t have happened, or at least it wouldn’t have happened due to?woocommerce-shipstation-integration??? And then I got to thinking, I wonder how many other Woocommerce customers there are that have some poorly coded plugin or theme that could interact poorly with this as well, so I decided to make this suggestion.

Viewing 1 replies (of 1 total)
  • Plugin Support Paulo P – a11n

    (@paulostp)

    Hello @shaunek,

    Thanks for taking the time to share your code suggestions. We have an internal repository to track issues with the WooCommerce ShipStation Integration plugin.

    I created an issue with the content you shared for the developer team to look into.

    I’m closing this topic, but we’ll write back if we have any follow-up questions.

    Thanks!

    Best,

Viewing 1 replies (of 1 total)
  • The topic ‘Suggested patch for perf and plugin compatibility’ is closed to new replies.