Make WordPress Core

Changeset 31153


Ignore:
Timestamp:
01/12/2015 12:19:34 AM (10 years ago)
Author:
pento
Message:

In get_avatar_data(), there's no need to return false if we couldn't find an avatar, as Gravatar can handle being given an empty email hash. This allows the default avatar to show when no email address is given.

See #21195

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r31114 r31153  
    33893389 *     Along with the arguments passed in $args, this will contain a couple of extra arguments.
    33903390 *
    3391  *     @type bool         $found_avatar True if we were able to find an avatar for this user,
    3392  *                                      false or not set if we couldn't.
    3393  *     @type false|string $url          The URL of the avatar we found, or false if we couldn't find an avatar.
     3391 *     @type bool   $found_avatar True if we were able to find an avatar for this user,
     3392 *                                false or not set if we couldn't.
     3393 *     @type string $url          The URL of the avatar we found.
    33943394 * }
    33953395 */
     
    35483548     * @param int|object|string $id_or_email   A user ID, email address, or comment object.
    35493549     */
    3550     $args = apply_filters( 'get_avatar_data', $args, $id_or_email );
    3551 
    3552     // Don't return a broken URL if we couldn't find the email hash, and none of the filters returned a different URL.
    3553     if ( ! $email_hash && $url === $args['url'] ) {
    3554         $args['url'] = false;
    3555     }
    3556 
    3557     return $args;
    3558 }
     3550    return apply_filters( 'get_avatar_data', $args, $id_or_email );
     3551}
  • trunk/tests/phpunit/tests/avatar.php

    r31152 r31153  
    9999    }
    100100
    101     /**
    102      * @ticket 21195
    103      */
    104     public function test_get_avatar_url_bad_id() {
    105         $this->assertFalse( get_avatar_url( false ) );
    106         $this->assertFalse( get_avatar_url( 100000 ) );
    107     }
    108 
    109101    protected $fakeURL;
    110102    /**
Note: See TracChangeset for help on using the changeset viewer.