• Resolved BuddyDev

    (@buddydev)


    Hi,
    Thank you for the plugin with such good features.

    While developing compatibility with our theme, we found out an issue with BadeOS.

    If you have large number of users, the number of queries gets linearly escalated.

    The reason is the function

    
    badgeos_register_achievements_list_shortcode
    

    There you are using a call to

    
    get_users()
    

    This causes 1 extra query per user as the users are not cached.

    You can change this to

    
    get_users( array( 'fields' => 'all_with_meta' ) )
    
    

    and WordPress will cache the users before trying to create user object.
    This will solve the issue.

    Hope it helps.

    Regards
    B

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author learningtimes

    (@learningtimes)

    Hi @buddydev

    We will update the code in our next release. Thanks for pointing us to this.

    FreshView

    (@dtopper)

    In what file would I make this change since we can’t wait for the next update to come out.

    Plugin Author learningtimes

    (@learningtimes)

    Hi @dtopper

    We are going to release a new version by tomorrow which will fix this issue. However, you can replace below code in the BadgeOS plugin file for a quick fix.

    /wp-content/plugins/badgeos/includes/shortcodes/badgeos_achievements_list.php line 22 to 26

    From:

    $users = get_users();
    $user_list = array();
    foreach( $users as $user ) {
    $user_list[ $user->ID ] = $user->user_login;
    }

    To

    global $wpdb;
    $user_list = array();
    $users = $wpdb->get_results( "SELECT ID, user_login FROM {$wpdb->users}" );
    if( $users ) {
    foreach ( $users as $user ) {
    $user_list[ $user->ID ] = $user->user_login;
    }
    }

    Thanks

    Plugin Author learningtimes

    (@learningtimes)

    Hi @dtopper @buddydev

    We have just released a new version of the plugin which has fixed this issue. Please update the plugin to the latest version.

    Thanks

    Plugin Author learningtimes

    (@learningtimes)

    Hi All

    Since we have not heard from you in a while, we are now closing this thread. If you still need help, don’t hesitate to let us know.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘BadgeOs slowdown due to linear queries and solution’ is closed to new replies.