Make WordPress Core


Ignore:
Timestamp:
09/03/2015 06:16:35 PM (10 years ago)
Author:
wonderboymusic
Message:

Introduce WP_Comment class to model/strongly-type rows from the comments database table. Inclusion of this class is a pre-req for some more general comment cleanup and sanity.

  • Takes inspiration from WP_Post and adds sanity to comment caching.
  • Clarifies when the current global value for $comment is returned. The current implementation in get_comment() introduces side effects and an occasion stale global value for $comment when comment caches are cleaned.
  • Strongly-types @param docs
  • This class is marked final for now

Props wonderboymusic, nacin.

See #32619.

File:
1 edited

Legend:

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

    r33805 r33891  
    34553455 *
    34563456 * @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash,
    3457  *                           user email, WP_User object, WP_Post object, or comment object.
     3457 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    34583458 * @param array $args {
    34593459 *     Optional. Arguments to return instead of the default arguments.
     
    34863486 * @since 4.2.0
    34873487 *
    3488  * @param mixed $id_or_email The Gravatar to check the data against. Accepts a user_id, gravatar md5 hash,
    3489  *                           user email, WP_User object, WP_Post object, or comment object.
     3488 * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     3489 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
    34903490 * @param array $args {
    34913491 *     Optional. Arguments to return instead of the default arguments.
     
    35873587     * @since 4.2.0
    35883588     *
    3589      * @param array             $args          Arguments passed to get_avatar_data(), after processing.
    3590      * @param int|object|string $id_or_email   A user ID, email address, or comment object.
     3589     * @param array  $args        Arguments passed to get_avatar_data(), after processing.
     3590     * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     3591     *                            user email, WP_User object, WP_Post object, or WP_Comment object.
    35913592     */
    35923593    $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
     
    36173618        // Post Object
    36183619        $user = get_user_by( 'id', (int) $id_or_email->post_author );
    3619     } elseif ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
    3620         // Comment Object
    3621 
     3620    } elseif ( $id_or_email instanceof WP_Comment ) {
    36223621        /**
    36233622         * Filter the list of allowed comment types for retrieving avatars.
     
    36823681     * @since 4.2.0
    36833682     *
    3684      * @param string            $url         The URL of the avatar.
    3685      * @param int|object|string $id_or_email A user ID, email address, or comment object.
    3686      * @param array             $args        Arguments passed to get_avatar_data(), after processing.
     3683     * @param string $url         The URL of the avatar.
     3684     * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     3685     *                            user email, WP_User object, WP_Post object, or WP_Comment object.
     3686     * @param array  $args        Arguments passed to get_avatar_data(), after processing.
    36873687     */
    36883688    $args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args );
     
    36933693     * @since 4.2.0
    36943694     *
    3695      * @param array             $args        Arguments passed to get_avatar_data(), after processing.
    3696      * @param int|object|string $id_or_email A user ID, email address, or comment object.
     3695     * @param array  $args        Arguments passed to get_avatar_data(), after processing.
     3696     * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     3697     *                            user email, WP_User object, WP_Post object, or WP_Comment object.
    36973698     */
    36983699    return apply_filters( 'get_avatar_data', $args, $id_or_email );
Note: See TracChangeset for help on using the changeset viewer.