Support » Plugin: Braintree for WooCommerce Payment Gateway » Performance improvement – Superfluous slow query on Admin

  • Resolved Jason

    (@galapogos01)


    Hi team

    I have found a performance issue that impacts the orders admin page on large sites.

    Every time the orders screen is loaded, the plugin calls process_capture_charge_bulk_order_action() which in turn calls _get_list_table( ‘WP_Posts_List_Table’ ); to get the current action. This is a very slow query on large sites.

    https://i.imgur.com/TjvWCia.jpg

    The function also bails if many other less expensive conditions are not met, eg. the check for order IDs being in the POST.

    Would it be possible for you to modify the order of the checks so that it bails on the less expensive conditions first and therefore avoids the expensive query if there are no charges to capture?

    This would speed up the life of site admins/users quite a lot 🙂

    Thanks,
    Jason

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support Martyn J. a11n

    (@martynmjones)

    Hey @galapogos01.

    I have found a performance issue that impacts the orders admin page on large sites.

    Thank you for sharing your findings. We appreciate all input from our users!

    I’ve passed along your message to our development team for further investigation. I don’t have an estimated timeframe as to when it may be addressed but we have all the details logged internally.

    I’ll mark this topic as resolved for now but please do open a new one if there’s anything else we can help with.

    Thanks again!
    Martyn

    Thread Starter Jason

    (@galapogos01)

    Would prefer to leave the ticket as unresolved until it gets resolved. Thanks, Jason

    Plugin Support B C. a11n

    (@battouly)

    Hi @galapogos01,

    That’s okay. We will update this thread if we get anything from the developers. Thanks!

    Thread Starter Jason

    (@galapogos01)

    Hi guys can I get an update on the backend ticket for this fix? It’s excruciating. Thanks.

    Thread Starter Jason

    (@galapogos01)

    I made this patch to do a less expensive call first (check if there are any order IDs on the POST to get payments for). Saves 0.5s on my order admin list load time.

                    if ( 'shop_order' === $typenow ) {
    
    +                        // make sure order IDs are submitted
    +                        if ( isset( $_REQUEST['post'] ) ) {
    +                                $order_ids = array_map( 'absint', $_REQUEST['post'] );
    +                        }
    +
    +                        // return if there are no orders to export
    +                        if ( empty( $order_ids ) ) {
    +                                return;
    +                        }
    +
                            // get the action
                            $wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
                            $action        = $wp_list_table->current_action();
    @@ -201,16 +211,6 @@
                            // security check
                            check_admin_referer( 'bulk-posts' );
    
    -                       // make sure order IDs are submitted
    -                       if ( isset( $_REQUEST['post'] ) ) {
    -                               $order_ids = array_map( 'absint', $_REQUEST['post'] );
    -                       }
    -
    -                       // return if there are no orders to export
    -                       if ( empty( $order_ids ) ) {
    -                               return;
    -                       }
    -
                            // give ourselves an unlimited timeout if possible
                            @set_time_limit( 0 );
    
    Plugin Support Rashed Ripon (a11n)

    (@rur165)

    Hi @galapogos01 ,

    I appreciate your taking the effort to improve the performance of this extension.

    While we do not have an open GitHub repository to request this patch to be added to the extension, you can submit a feature request with the details so that our developers can consider including your suggestion.

    Thank you.

    Thread Starter Jason

    (@galapogos01)

    Unfortunately when I try to I keep getting stuck in a link to authorise my account. Any ideas?

    Jason

    Plugin Support Jim W – a11n

    (@thracefulton)

    Hi @galapogos01,

    Unfortunately when I try to I keep getting stuck in a link to authorise my account. Any ideas?

    It sounds like you’re referring to 2-factor authentication for your WooCommerce.com account, is that correct?

    If you need assistance with recovering access to your account, please send us an email to help@wordpress.com or create a ticket here.

    Thanks!

    Thread Starter Jason

    (@galapogos01)

    No, and I don’t need help recovering my account. There is some kind of issue with auth.

    Can you raise the feature request please?

    Plugin Support Berg (woo-hc)

    (@hegenberg)

    Hi @galapogos01

    I have tested the feature request form with a regular WooCommerce account and could submit it without any issues.
    Could you kindly try it out one more time, by following the steps below?

    1. If logged in, log out from your WordPress.com / WooCommerce account via this link: https://woocommerce.com/wp-login.php?action=logout
    2. Log in back to your WordPress.com / WooCommerce account by going to: https://woocommerce.com/my-dashboard/ (or create a new free account)
    3. Once logged in, head again to the feature request page: https://woocommerce.com/feature-requests/woocommerce-gateway-paypal-powered-by-braintree/

    We appreciate your effort and want to make sure the feature request is put forward, so please let us know if the steps above doesn’t help.

    Thread Starter Jason

    (@galapogos01)

    Thanks those steps stopped the auth loop.

    Hopefully performance is not ignored as a feature.

    Jason

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Performance improvement – Superfluous slow query on Admin’ is closed to new replies.