WordPress.org

Make WordPress Core

Ticket #11423: 11423.diff

File 11423.diff, 1.5 KB (added by Denis-de-Bernardy, 4 years ago)
  • wp-includes/query.php

     
    19861986                                } 
    19871987                        } 
    19881988                        $q['author_name'] = sanitize_title($q['author_name']); 
    1989                         $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); 
    19901989                        $q['author'] = get_user_by('slug', $q['author_name']); 
    19911990                        if ( $q['author'] ) 
    19921991                                $q['author'] = $q['author']->ID; 
     1992                        else 
     1993                                $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); 
    19931994                        $whichauthor .= " AND ($wpdb->posts.post_author = ".absint($q['author']).')'; 
    19941995                } 
    19951996 
  • wp-includes/general-template.php

     
    458458                $title = $title->display_name; 
    459459        } 
    460460        if ( !empty($author_name) ) { 
    461                 // We do a direct query here because we don't cache by nicename. 
    462                 $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name)); 
     461                if ( ( $user_id = wp_cache_get($author_name, 'userslugs') ) && ( $user = wp_cache_get($user_id, 'users') ) ) 
     462                        $title = $user->display_name; 
     463                else 
     464                        $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name)); 
    463465        } 
    464466 
    465467        // If there's a month