WordPress.org

Make WordPress Core

Changeset 13617


Ignore:
Timestamp:
03/08/10 14:30:17 (4 years ago)
Author:
nacin
Message:

Fix warning in users.php. Fixes #12555

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/users.php

    r13576 r13617  
    371371 
    372372    $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; 
    373     echo "\n\t", user_row($user_object, $style, $role, $post_counts[(string)$userid]); 
     373    echo "\n\t", user_row($user_object, $style, $role, isset( $post_counts[ $userid ] ) ? $post_counts[ $userid ] : 0 ); 
    374374} 
    375375?> 
  • trunk/wp-includes/user.php

    r13576 r13617  
    168168function count_many_users_posts($users) { 
    169169    global $wpdb; 
    170      
    171     if (0 == count($users)) 
    172         return array(); 
    173          
    174     $userlist = implode(',', $users); 
    175     $where = get_posts_by_author_sql('post'); 
     170 
     171    $count = array(); 
     172    if ( ! count( $users ) ) 
     173        return $count; 
     174 
     175    $userlist = implode( ',', $users ); 
     176    $where = get_posts_by_author_sql( 'post' ); 
    176177 
    177178    $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N ); 
    178179 
    179     $count = array(); 
    180     foreach($result as $row) { 
    181         $count[$row[0]] = $row[1]; 
    182     } 
    183  
    184     foreach($users as $id) { 
    185         $id = (string) $id; 
    186         if (!isset($count[$id])) 
    187             $count[$id] = 0; 
     180    if ( ! $result ) 
     181        return $count; 
     182 
     183    foreach ( $result as $row ) { 
     184        $count[ $row[0] ] = $row[1]; 
     185    } 
     186 
     187    foreach ( $users as $id ) { 
     188        if ( ! isset( $count[ $id ] ) ) 
     189            $count[ $id ] = 0; 
    188190    } 
    189191 
Note: See TracChangeset for help on using the changeset viewer.