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-forums/bp-forums-functions.php

    r4764 r4770  
    321321    // Fetch the topic's last poster details
    322322    $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ) );
    323     for ( $i = 0; $i < count( $topics ); $i++ ) {
     323    for ( $i = 0, $count = count( $topics ); $i < $count; ++$i ) {
    324324        foreach ( (array)$poster_details as $poster ) {
    325325            if ( $poster->topic_id == $topics[$i]->topic_id ) {
     
    335335    if ( bp_is_active( 'xprofile' ) ) {
    336336        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) );
    337         for ( $i = 0; $i < count( $topics ); $i++ ) {
     337        for ( $i = 0, $count = count( $topics ); $i < $count; ++$i ) {
    338338            foreach ( (array)$poster_names as $name ) {
    339339                if ( $name->topic_id == $topics[$i]->topic_id )
     
    439439    $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ) );
    440440
    441     for ( $i = 0; $i < count( $posts ); $i++ ) {
     441    for ( $i = 0, $count = count( $posts ); $i < $count; ++$i ) {
    442442        foreach ( (array)$poster_details as $poster ) {
    443443            if ( $poster->user_id == $posts[$i]->poster_id ) {
     
    453453    if ( bp_is_active( 'xprofile' ) ) {
    454454        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) );
    455         for ( $i = 0; $i < count( $posts ); $i++ ) {
     455        for ( $i = 0, $count = count( $posts ); $i < $count; ++$i ) {
    456456            foreach ( (array)$poster_names as $name ) {
    457457                if ( isset( $topics[$i] ) && $name->user_id == $topics[$i]->user_id )
Note: See TracChangeset for help on using the changeset viewer.