Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/21/2011 10:27:09 PM (13 years ago)
Author:
djpaul
Message:

Tune up 'for' loops. Fixes #2985, props cnorris23 and r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r4764 r4770  
    542542        /* Fetch the logged in users status within each group */
    543543        $user_status = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_confirmed = 1 AND is_banned = 0", $bp->loggedin_user->id ) );
    544         for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
     544        for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
    545545            $paged_groups[$i]->is_member = false;
    546546
     
    552552
    553553        $user_banned = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE is_banned = 1 AND user_id = %d AND group_id IN ( {$group_ids} )", $bp->loggedin_user->id ) );
    554         for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
     554        for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
    555555            $paged_groups[$i]->is_banned = false;
    556556
     
    11061106        if ( bp_is_active( 'friends' ) ) {
    11071107            $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
    1108             for ( $i = 0; $i < count( $members ); $i++ ) {
     1108            for ( $i = 0, $count = count( $members ); $i < $count; ++$i ) {
    11091109                foreach ( (array)$friend_status as $status ) {
    11101110                    if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id )
Note: See TracChangeset for help on using the changeset viewer.