WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#25803 closed defect (bug) (fixed)

wrong url for get_avatar

Reported by: lite3 Owned by: SergeyBiryukov
Milestone: 3.8 Priority: normal
Severity: major Version:
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

description

  1. one user registered at website.
  2. write a comment.
  3. remove the user.
  4. the user's avatar is wrong.

solve it

if not had user for $comment->user_id, use $comment->comment_author_email

Attachments (1)

25803.diff (501 bytes) - added by mauryaratan 6 years ago.
check if $email is blank

Download all attachments as: .zip

Change History (7)

#1 follow-up: @mauryaratan
6 years ago

  • Keywords has-patch added

#2 in reply to: ↑ 1 @lite3
6 years ago

Replying to mauryaratan:
not here. in function get_avatar of wp-includes/pluggable.php.

===old code:===

// No avatar for pingbacks or trackbacks
$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
        return false;

if ( !empty($id_or_email->user_id) ) {
        $id = (int) $id_or_email->user_id;
        $user = get_userdata($id);
        if ( $user)
                $email = $user->user_email;
} elseif ( !empty($id_or_email->comment_author_email) ) {
        $email = $id_or_email->comment_author_email;
}

===new code:===

// No avatar for pingbacks or trackbacks
$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
        return false;

if ( !empty($id_or_email->user_id) ) {
        $id = (int) $id_or_email->user_id;
        $user = get_userdata($id);
        if ( $user)
                $email = $user->user_email;
}
if ( $email === '' && !empty($id_or_email->comment_author_email) ) {
        $email = $id_or_email->comment_author_email;
}

#3 @lite3
6 years ago

  • Keywords has-patch removed

@mauryaratan
6 years ago

check if $email is blank

#4 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 3.8

#5 @mauryaratan
6 years ago

  • Keywords has-patch added

You’re right there wasn't any need to pass the email specifically instead check for the email it it's blank. Edited the patch :)

#6 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 26000:

Fall back to comment author email in get_avatar() if the user who left the comment no longer exists.

props mauryaratan, lite3.
fixes #25803.

Note: See TracTickets for help on using tickets.