Make WordPress Core

Changeset 33891


Ignore:
Timestamp:
09/03/2015 06:16:35 PM (11 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.

Location:
trunk/src
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-comment.php

    r33774 r33891  
    172172 * @since 3.0.0
    173173 *
    174  * @param object $comment Comment object.
     174 * @param WP_Comment $comment Comment object.
    175175 */
    176176do_action( 'add_meta_boxes_comment', $comment );
  • trunk/src/wp-admin/includes/comment.php

    r32672 r33891  
    7575
    7676/**
    77  * Returns a comment object based on comment ID.
     77 * Returns a WP_Comment object based on comment ID.
    7878 *
    7979 * @since 2.0.0
    8080 *
    8181 * @param int $id ID of comment to retrieve.
    82  * @return object|false Comment if found. False on failure.
     82 * @return WP_Comment|false Comment if found. False on failure.
    8383 */
    8484function get_comment_to_edit( $id ) {
  • trunk/src/wp-admin/includes/dashboard.php

    r33833 r33891  
    549549
    550550/**
    551  * @global object $comment
    552  *
    553  * @param object $comment
    554  * @param bool   $show_date
     551 * @global WP_Comment $comment
     552 *
     553 * @param WP_Comment $comment
     554 * @param bool       $show_date
    555555 */
    556556function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
    … …  
    604604                 * @since 2.6.0
    605605                 *
    606                  * @param array  $actions An array of comment actions. Default actions include:
    607                  *                        'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
    608                  *                        'Delete', and 'Trash'.
    609                  * @param object $comment The comment object.
     606                 * @param array      $actions An array of comment actions. Default actions include:
     607                 *                            'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
     608                 *                            'Delete', and 'Trash'.
     609                 * @param WP_Comment $comment The comment object.
    610610                 */
    611611                $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
  • trunk/src/wp-admin/includes/export.php

    r32964 r33891  
    474474<?php   endforeach;
    475475
    476                 $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
     476                $_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
     477                $comments = array_map( 'get_comment', $_comments );
    477478                foreach ( $comments as $c ) : ?>
    478479                <wp:comment>
  • trunk/src/wp-admin/includes/template.php

    r33774 r33891  
    744744 * @since 0.71
    745745 *
    746  * @global WP_Locale $wp_locale
    747  * @global object    $comment
     746 * @global WP_Locale  $wp_locale
     747 * @global WP_Comment $comment
    748748 *
    749749 * @param int|bool $edit      Accepts 1|true for editing the date, 0|false for adding the date.
  • trunk/src/wp-comments-post.php

    r31090 r33891  
    147147 * @since 3.4.0
    148148 *
    149  * @param object $comment Comment object.
    150  * @param WP_User $user   User object. The user may not exist.
     149 * @param WP_Comment $comment Comment object.
     150 * @param WP_User    $user    User object. The user may not exist.
    151151 */
    152152do_action( 'set_comment_cookies', $comment, $user );
    … …  
    159159 * @since 2.0.5
    160160 *
    161  * @param string $location The 'redirect_to' URI sent via $_POST.
    162  * @param object $comment  Comment object.
     161 * @param string     $location The 'redirect_to' URI sent via $_POST.
     162 * @param WP_Comment $comment  Comment object.
    163163 */
    164164$location = apply_filters( 'comment_post_redirect', $location, $comment );
  • trunk/src/wp-includes/class-wp-comment-query.php

    r33750 r33891  
    666666                 * @param WP_Comment_Query &$this    Current instance of WP_Comment_Query, passed by reference.
    667667                 */
    668                 $comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) );
     668                $_comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) );
     669
     670                // Convert to WP_Comment instances
     671                $comments = array_map( 'get_comment', $_comments );
    669672
    670673                wp_cache_add( $cache_key, $comments, 'comment' );
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r33885 r33891  
    10431043                 * @since 3.4.0
    10441044                 *
    1045                  * @param array  $_comment An array of prepared comment data.
    1046                  * @param object $comment  Comment object.
     1045                 * @param array      $_comment An array of prepared comment data.
     1046                 * @param WP_Comment $comment  Comment object.
    10471047                 */
    10481048                return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment );
  • trunk/src/wp-includes/comment-functions.php

    r33822 r33891  
    165165 * @global object $comment
    166166 *
    167  * @param object|string|int $comment Comment to retrieve.
     167 * @param WP_Comment|string|int $comment Comment to retrieve.
    168168 * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants.
    169  * @return object|array|null Depends on $output value.
     169 * @return WP_Comment|array|null Depends on $output value.
    170170 */
    171171function get_comment(&$comment, $output = OBJECT) {
    172         global $wpdb;
    173 
    174         if ( empty($comment) ) {
    175                 if ( isset($GLOBALS['comment']) )
    176                         $_comment = & $GLOBALS['comment'];
    177                 else
    178                         $_comment = null;
    179         } elseif ( is_object($comment) ) {
    180                 wp_cache_add($comment->comment_ID, $comment, 'comment');
     172        if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) {
     173                $comment = $GLOBALS['comment'];
     174        }
     175
     176        if ( $comment instanceof WP_Comment ) {
    181177                $_comment = $comment;
     178        } elseif ( is_object( $comment ) ) {
     179                $_comment = new WP_Comment( $comment );
    182180        } else {
    183                 if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {
    184                         $_comment = & $GLOBALS['comment'];
    185                 } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) {
    186                         $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment));
    187                         if ( ! $_comment )
    188                                 return null;
    189                         wp_cache_add($_comment->comment_ID, $_comment, 'comment');
    190                 }
     181                $_comment = WP_Comment::get_instance( $comment );
     182        }
     183
     184        if ( ! $_comment ) {
     185                return null;
    191186        }
    192187
    … …  
    203198                return $_comment;
    204199        } elseif ( $output == ARRAY_A ) {
    205                 $__comment = get_object_vars($_comment);
    206                 return $__comment;
     200                return $_comment->to_array();
    207201        } elseif ( $output == ARRAY_N ) {
    208                 $__comment = array_values(get_object_vars($_comment));
    209                 return $__comment;
    210         } else {
    211                 return $_comment;
    212         }
     202                return array_values( $_comment->to_array() );
     203        }
     204        return $_comment;
    213205}
    214206
    … …  
    480472 * to recall previous comments by this commentator that are still held in moderation.
    481473 *
    482  * @param object $comment Comment object.
    483  * @param object $user Comment author's object.
     474 * @param WP_Comment $comment Comment object.
     475 * @param object     $user    Comment author's object.
    484476 *
    485477 * @since 3.4.0
    … …  
    761753 * @global WP_Query $wp_query
    762754 *
    763  * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
     755 * @param array $comments Optional array of WP_Comment objects. Defaults to $wp_query->comments
    764756 * @param int   $per_page Optional comments per page.
    765757 * @param bool  $threaded Optional control over flat or threaded comments.
    … …  
    12891281                 * @since 2.7.0
    12901282                 *
    1291                  * @param object $comment Comment object.
     1283                 * @param WP_Comment $comment Comment object.
    12921284                 */
    12931285                do_action( "comment_{$old_status}_to_{$new_status}", $comment );
    … …  
    13041296         * @since 2.7.0
    13051297         *
    1306          * @param int $comment_ID The comment ID.
    1307          * @param obj $comment    Comment object.
     1298         * @param int        $comment_ID The comment ID.
     1299         * @param WP_Comment $comment    Comment object.
    13081300         */
    13091301        do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );
    … …  
    14241416         * @since 2.8.0
    14251417         *
    1426          * @param int $id      The comment ID.
    1427          * @param obj $comment Comment object.
     1418         * @param int        $id      The comment ID.
     1419         * @param WP_Comment $comment Comment object.
    14281420         */
    14291421        do_action( 'wp_insert_comment', $id, $comment );
  • trunk/src/wp-includes/comment-template.php

    r33047 r33891  
    3838         * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    3939         *
     40         * @param string     $author     The comment author's username.
     41         * @param int        $comment_ID The comment ID.
     42         * @param WP_Comment $comment    The comment object.
     43         */
     44        return apply_filters( 'get_comment_author', $author, $comment_ID, $comment );
     45}
     46
     47/**
     48 * Displays the author of the current comment.
     49 *
     50 * @since 0.71
     51 *
     52 * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment.
     53 */
     54function comment_author( $comment_ID = 0 ) {
     55        $author = get_comment_author( $comment_ID );
     56
     57        /**
     58         * Filter the comment author's name for display.
     59         *
     60         * @since 1.2.0
     61         * @since 4.1.0 The `$comment_ID` parameter was added.
     62         *
    4063         * @param string $author     The comment author's username.
    4164         * @param int    $comment_ID The comment ID.
    42          * @param object $comment    The comment object.
    43          */
    44         return apply_filters( 'get_comment_author', $author, $comment_ID, $comment );
    45 }
    46 
    47 /**
    48  * Displays the author of the current comment.
    49  *
    50  * @since 0.71
    51  *
    52  * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment.
    53  */
    54 function comment_author( $comment_ID = 0 ) {
    55         $author = get_comment_author( $comment_ID );
    56 
    57         /**
    58          * Filter the comment author's name for display.
    59          *
    60          * @since 1.2.0
    61          * @since 4.1.0 The `$comment_ID` parameter was added.
    62          *
    63          * @param string $author     The comment author's username.
    64          * @param int    $comment_ID The comment ID.
    6565         */
    6666        echo apply_filters( 'comment_author', $author, $comment_ID );
    … …  
    8484         * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    8585         *
    86          * @param string $comment_author_email The comment author's email address.
    87          * @param int    $comment_ID           The comment ID.
    88          * @param object $comment              The comment object.
     86         * @param string     $comment_author_email The comment author's email address.
     87         * @param int        $comment_ID           The comment ID.
     88         * @param WP_Comment $comment              The comment object.
    8989         */
    9090        return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment_ID, $comment );
    … …  
    171171         * @since 4.1.0 The `$comment` parameter was added.
    172172         *
    173          * @param string $comment_author_email The comment author's email address.
    174          * @param object $comment              The comment object.
     173         * @param string     $comment_author_email The comment author's email address.
     174         * @param WP_Comment $comment              The comment object.
    175175         */
    176176        $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
    … …  
    251251         * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    252252         *
    253          * @param string $comment_author_IP The comment author's IP address.
    254          * @param int    $comment_ID        The comment ID.
    255          * @param object $comment           The comment object.
     253         * @param string     $comment_author_IP The comment author's IP address.
     254         * @param int        $comment_ID        The comment ID.
     255         * @param WP_Comment $comment           The comment object.
    256256         */
    257257        return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment_ID, $comment );
    … …  
    290290         * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    291291         *
    292          * @param string $url        The comment author's URL.
    293          * @param int    $comment_ID The comment ID.
    294          * @param object $comment    The comment object.
     292         * @param string     $url        The comment author's URL.
     293         * @param int        $comment_ID The comment ID.
     294         * @param WP_Comment $comment    The comment object.
    295295         */
    296296        return apply_filters( 'get_comment_author_url', $url, $comment_ID, $comment );
    … …  
    509509         * @param string|int $date    Formatted date string or Unix timestamp.
    510510         * @param string     $d       The format of the date.
    511          * @param object    $comment The comment object.
     511         * @param WP_Comment $comment The comment object.
    512512         */
    513513        return apply_filters( 'get_comment_date', $date, $d, $comment );
    … …  
    564564         * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    565565         *
    566          * @param string $excerpt    The comment excerpt text.
    567          * @param int    $comment_ID The comment ID.
    568          * @param object $comment    The comment object.
     566         * @param string     $excerpt    The comment excerpt text.
     567         * @param int        $comment_ID The comment ID.
     568         * @param WP_Comment $comment    The comment object.
    569569         */
    570570        return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment );
    … …  
    612612         * @since 4.1.0 The `$comment_ID` parameter was added.
    613613         *
    614          * @param int    $comment_ID The current comment ID.
    615          * @param object $comment    The comment object.
     614         * @param int        $comment_ID The current comment ID.
     615         * @param WP_Comment $comment    The comment object.
    616616         */
    617617        return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
    … …  
    637637 * @global bool       $in_comment_loop
    638638 *
    639  * @param mixed $comment Comment to retrieve. Default current comment.
    640  * @param array $args    Optional. An array of arguments to override the defaults.
     639 * @param WP_Comment|int|null $comment Comment to retrieve. Default current comment.
     640 * @param array               $args    Optional. An array of arguments to override the defaults.
    641641 * @return string The permalink to the given comment.
    642642 */
    … …  
    682682         * @see get_page_of_comment()
    683683         *
    684          * @param string $link    The comment permalink with '#comment-$id' appended.
    685          * @param object $comment The current comment object.
    686          * @param array  $args    An array of arguments to override the defaults.
     684         * @param string     $link    The comment permalink with '#comment-$id' appended.
     685         * @param WP_Comment $comment The current comment object.
     686         * @param array      $args    An array of arguments to override the defaults.
    687687         */
    688688        return apply_filters( 'get_comment_link', $link, $comment, $args );
    … …  
    826826         * @see Walker_Comment::comment()
    827827         *
    828          * @param string $comment_content Text of the comment.
    829          * @param object $comment         The comment object.
    830          * @param array  $args            An array of arguments.
     828         * @param string     $comment_content Text of the comment.
     829         * @param WP_Comment $comment         The comment object.
     830         * @param array      $args            An array of arguments.
    831831         */
    832832        return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
    … …  
    854854         * @see Walker_Comment::comment()
    855855         *
    856          * @param string $comment_text Text of the current comment.
    857          * @param object $comment      The comment object.
    858          * @param array  $args         An array of arguments.
     856         * @param string     $comment_text Text of the current comment.
     857         * @param WP_Comment $comment      The comment object.
     858         * @param array      $args         An array of arguments.
    859859         */
    860860        echo apply_filters( 'comment_text', $comment_text, $comment, $args );
    … …  
    891891         * @param bool       $gmt       Whether the GMT date is in use.
    892892         * @param bool       $translate Whether the time is translated.
    893          * @param object    $comment   The comment object.
     893         * @param WP_Comment $comment   The comment object.
    894894         */
    895895        return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
    … …  
    926926         * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    927927         *
    928          * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
    929          * @param int    $comment_ID   The comment ID.
    930          * @param object $comment      The comment object.
     928         * @param string     $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
     929         * @param int        $comment_ID   The comment ID.
     930         * @param WP_Comment $comment      The comment object.
    931931         */
    932932        return apply_filters( 'get_comment_type', $comment->comment_type, $comment_ID, $comment );
    … …  
    18591859         * @see wp_list_comments()
    18601860         *
    1861          * @param string $output  Passed by reference. Used to append additional content.
    1862          * @param object $comment The comment object. Default current comment.
    1863          * @param int    $depth   Depth of comment.
    1864          * @param array  $args    An array of arguments.
     1861         * @param string     $output  Passed by reference. Used to append additional content.
     1862         * @param WP_Comment $comment The comment object. Default current comment.
     1863         * @param int        $depth   Depth of comment.
     1864         * @param array      $args    An array of arguments.
    18651865         */
    18661866        public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
    … …  
    18851885         * @see wp_list_comments()
    18861886         *
    1887          * @param object $comment The comment object.
    1888          * @param int    $depth   Depth of comment.
    1889          * @param array  $args    An array of arguments.
     1887         * @param WP_Comment $comment The comment object.
     1888         * @param int        $depth   Depth of comment.
     1889         * @param array      $args    An array of arguments.
    18901890         */
    18911891        protected function ping( $comment, $depth, $args ) {
    … …  
    20492049 *     @type bool   $echo              Whether to echo the output or return it. Default true.
    20502050 * }
    2051  * @param array $comments Optional. Array of comment objects.
     2051 * @param array $comments Optional. Array of WP_Comment objects.
    20522052 */
    20532053function wp_list_comments( $args = array(), $comments = null ) {
  • trunk/src/wp-includes/comment.php

    r33750 r33891  
    77 */
    88
     9require_once( ABSPATH . WPINC . '/class-wp-comment.php' );
    910require_once( ABSPATH . WPINC . '/class-wp-comment-query.php' );
    1011require_once( ABSPATH . WPINC . '/comment-functions.php' );
  • trunk/src/wp-includes/feed.php

    r33605 r33891  
    265265 * @since 2.5.0
    266266 *
    267  * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
     267 * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     268 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
    268269 */
    269270function comment_guid($comment_id = null) {
    … …  
    276277 * @since 2.5.0
    277278 *
    278  * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
     279 * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     280 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
    279281 * @return false|string false on failure or guid for comment on success.
    280282 */
  • 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 );
  • trunk/src/wp-includes/pluggable.php

    r33827 r33891  
    21912191 *
    21922192 * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
    2193  *                           user email, WP_User object, WP_Post object, or comment object.
     2193 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
    21942194 * @param int    $size       Optional. Height and width of the avatar image file in pixels. Default 96.
    21952195 * @param string $default    Optional. URL for the default image or a default type. Accepts '404'
    … …  
    22592259         * @since 4.2.0
    22602260         *
    2261          * @param string            $avatar      HTML for the user's avatar. Default null.
    2262          * @param int|object|string $id_or_email A user ID, email address, or comment object.
    2263          * @param array             $args        Arguments passed to get_avatar_url(), after processing.
     2261         * @param string $avatar      HTML for the user's avatar. Default null.
     2262         * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     2263         *                            user email, WP_User object, WP_Post object, or WP_Comment object.
     2264         * @param array  $args        Arguments passed to get_avatar_url(), after processing.
    22642265         */
    22652266        $avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args );
    … …  
    23152316         * @since 4.2.0 The `$args` parameter was added.
    23162317         *
    2317          * @param string            $avatar      &lt;img&gt; tag for the user's avatar.
    2318          * @param int|object|string $id_or_email A user ID, email address, or comment object.
    2319          * @param int               $size        Square avatar width and height in pixels to retrieve.
    2320          * @param string            $alt         Alternative text to use in the avatar image tag.
     2318         * @param string $avatar      &lt;img&gt; tag for the user's avatar.
     2319         * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     2320         *                            user email, WP_User object, WP_Post object, or WP_Comment object.
     2321         * @param int    $size        Square avatar width and height in pixels to retrieve.
     2322         * @param string $alt         Alternative text to use in the avatar image tag.
    23212323         *                                       Default empty.
    2322          * @param array             $args        Arguments passed to get_avatar_data(), after processing.
     2324         * @param array  $args        Arguments passed to get_avatar_data(), after processing.
    23232325         */
    23242326        return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
  • trunk/src/wp-includes/query.php

    r33734 r33891  
    31873187                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    31883188
    3189                         $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits");
     3189                        $comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits");
     3190                        // Convert to WP_Comment
     3191                        $this->comments = array_map( 'get_comment', $comments );
    31903192                        $this->comment_count = count($this->comments);
    31913193
    … …  
    35583560
    35593561                        $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits";
    3560                         $this->comments = $wpdb->get_results($comments_request);
     3562                        $comments = $wpdb->get_results($comments_request);
     3563                        // Convert to WP_Comment
     3564                        $this->comments = array_map( 'get_comment', $comments );
    35613565                        $this->comment_count = count($this->comments);
    35623566                }
    … …  
    38133817
    38143818        /**
    3815          * Iterate current comment index and return comment object.
     3819         * Iterate current comment index and return WP_Comment object.
    38163820         *
    38173821         * @since 2.2.0
    38183822         * @access public
    38193823         *
    3820          * @return object Comment object.
     3824         * @return WP_Comment Comment object.
    38213825         */
    38223826        public function next_comment() {
Note: See TracChangeset for help on using the changeset viewer.