Make WordPress Core

Ticket #40143: 40143.diff

File 40143.diff, 24.3 KB (added by david.binda, 16 months ago)
  • src/wp-includes/comment-template.php

     
    2424function get_comment_author( $comment_id = 0 ) {
    2525        $comment = get_comment( $comment_id );
    2626
    27         $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : $comment_id;
     27        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    2828
    29         if ( empty( $comment->comment_author ) ) {
    30                 $user = ! empty( $comment->user_id ) ? get_userdata( $comment->user_id ) : false;
    31                 if ( $user ) {
     29        if ( $comment ) {
     30                if ( $comment->comment_author ) {
     31                        $comment_author = $comment->comment_author;
     32                } elseif ( ! empty( $comment->user_id ) ) {
     33                        $user = get_userdata( $comment->user_id );
    3234                        $comment_author = $user->display_name;
    3335                } else {
    3436                        $comment_author = __( 'Anonymous' );
    3537                }
    3638        } else {
    37                 $comment_author = $comment->comment_author;
     39                $comment_author = '';
    3840        }
    3941
    4042        /**
     
    4345         * @since 1.5.0
    4446         * @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
    4547         *
    46          * @param string     $comment_author The comment author's username.
    47          * @param string     $comment_id     The comment ID as a numeric string.
    48          * @param WP_Comment $comment        The comment object.
     48         * @param string          $comment_author The comment author's username.
     49         * @param string          $comment_id     The comment ID as a numeric string.
     50         * @param WP_Comment|null $comment        The comment object.
    4951         */
    5052        return apply_filters( 'get_comment_author', $comment_author, $comment_id, $comment );
    5153}
     
    6264function comment_author( $comment_id = 0 ) {
    6365        $comment = get_comment( $comment_id );
    6466
    65         $comment_author = get_comment_author( $comment );
     67        $comment_author = $comment ? get_comment_author( $comment ) : '';
     68
     69        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    6670
    6771        /**
    6872         * Filters the comment author's name for display.
     
    7377         * @param string $comment_author The comment author's username.
    7478         * @param string $comment_id     The comment ID as a numeric string.
    7579         */
    76         echo apply_filters( 'comment_author', $comment_author, $comment->comment_ID );
     80        echo apply_filters( 'comment_author', $comment_author, $comment_id );
    7781}
    7882
    7983/**
     
    8993function get_comment_author_email( $comment_id = 0 ) {
    9094        $comment = get_comment( $comment_id );
    9195
     96        $comment_author_email = $comment ? $comment->comment_author_email : '';
     97
     98        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
     99
    92100        /**
    93101         * Filters the comment author's returned email address.
    94102         *
    95103         * @since 1.5.0
    96104         * @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
    97105         *
    98          * @param string     $comment_author_email The comment author's email address.
    99          * @param string     $comment_id           The comment ID as a numeric string.
    100          * @param WP_Comment $comment              The comment object.
     106         * @param string          $comment_author_email The comment author's email address.
     107         * @param string          $comment_id           The comment ID as a numeric string.
     108         * @param WP_Comment|null $comment              The comment object.
    101109         */
    102         return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment );
     110        return apply_filters( 'get_comment_author_email', $comment_author_email, $comment_id, $comment );
    103111}
    104112
    105113/**
     
    120128function comment_author_email( $comment_id = 0 ) {
    121129        $comment = get_comment( $comment_id );
    122130
    123         $comment_author_email = get_comment_author_email( $comment );
     131        $comment_author_email = $comment ? get_comment_author_email( $comment ) : '';
     132
     133        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    124134
    125135        /**
    126136         * Filters the comment author's email for display.
     
    131141         * @param string $comment_author_email The comment author's email address.
    132142         * @param string $comment_id           The comment ID as a numeric string.
    133143         */
    134         echo apply_filters( 'author_email', $comment_author_email, $comment->comment_ID );
     144        echo apply_filters( 'author_email', $comment_author_email, $comment_id );
    135145}
    136146
    137147/**
     
    182192function get_comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null ) {
    183193        $comment = get_comment( $comment );
    184194
     195        $comment_author_email = $comment ? $comment->comment_author_email : '';
     196
    185197        /**
    186198         * Filters the comment author's email for display.
    187199         *
     
    191203         * @since 1.2.0
    192204         * @since 4.1.0 The `$comment` parameter was added.
    193205         *
    194          * @param string     $comment_author_email The comment author's email address.
    195          * @param WP_Comment $comment              The comment object.
     206         * @param string          $comment_author_email The comment author's email address.
     207         * @param WP_Comment|null $comment              The comment object.
    196208         */
    197         $comment_author_email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
     209        $comment_author_email = apply_filters( 'comment_email', $comment_author_email, $comment );
    198210
    199         if ( ( ! empty( $comment_author_email ) ) && ( '@' !== $comment_author_email ) ) {
    200                 $display = ( '' !== $link_text ) ? $link_text : $comment_author_email;
     211        if ( $comment_author_email && ( '@' !== $comment_author_email ) ) {
     212                $display = $link_text ? $link_text : $comment_author_email;
    201213
    202214                $comment_author_email_link = $before . sprintf(
    203215                        '<a href="%1$s">%2$s</a>',
     
    229241
    230242        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    231243
    232         $comment_author_url = get_comment_author_url( $comment );
    233         $comment_author     = get_comment_author( $comment );
     244        $comment_author_url = $comment ? get_comment_author_url( $comment ) : '';
     245        $comment_author     = $comment ? get_comment_author( $comment ) : '';
    234246
    235247        if ( empty( $comment_author_url ) || 'http://' === $comment_author_url ) {
    236248                $comment_author_link = $comment_author;
     
    248260                 *
    249261                 * @since 6.2.0
    250262                 *
    251                  * @param string[]   $rel_parts An array of strings representing the rel tags
    252                  *                              which will be joined into the anchor's rel attribute.
    253                  * @param WP_Comment $comment   The comment object.
     263                 * @param string[]        $rel_parts An array of strings representing the rel tags
     264                 *                                   which will be joined into the anchor's rel attribute.
     265                 * @param WP_Comment|null $comment   The comment object.
    254266                 */
    255267                $rel_parts = apply_filters( 'comment_author_link_rel', $rel_parts, $comment );
    256268
     
    307319function get_comment_author_IP( $comment_id = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    308320        $comment = get_comment( $comment_id );
    309321
     322        $comment_author_ip = $comment ? $comment->comment_author_IP : '';
     323
     324        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
     325
    310326        /**
    311327         * Filters the comment author's returned IP address.
    312328         *
    313329         * @since 1.5.0
    314330         * @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
    315331         *
    316          * @param string     $comment_author_ip The comment author's IP address, or an empty string if it's not available.
    317          * @param string     $comment_id        The comment ID as a numeric string.
    318          * @param WP_Comment $comment           The comment object.
     332         * @param string          $comment_author_ip The comment author's IP address, or an empty string if it's not available.
     333         * @param string          $comment_id        The comment ID as a numeric string.
     334         * @param WP_Comment|null $comment           The comment object.
    319335         */
    320         return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     336        return apply_filters( 'get_comment_author_IP', $comment_author_ip, $comment_id, $comment );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    321337}
    322338
    323339/**
     
    346362function get_comment_author_url( $comment_id = 0 ) {
    347363        $comment = get_comment( $comment_id );
    348364
    349         $comment_author_url = '';
    350         $comment_id         = 0;
    351 
    352         if ( ! empty( $comment ) ) {
    353                 $comment_author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url;
    354                 $comment_author_url = esc_url( $comment_author_url, array( 'http', 'https' ) );
     365       
     366        if ( $comment && 'http://' !== $comment->comment_author_url ) {
     367                $comment_author_url = esc_url( $comment->comment_author_url, array( 'http', 'https' ) );
     368        } else {
     369                $comment_author_url = '';
     370        }
    355371
    356                 $comment_id = $comment->comment_ID;
    357         }
     372        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    358373
    359374        /**
    360375         * Filters the comment author's URL.
     
    366381         * @param string|int      $comment_id         The comment ID as a numeric string, or 0 if not found.
    367382         * @param WP_Comment|null $comment            The comment object, or null if not found.
    368383         */
    369         return apply_filters( 'get_comment_author_url', $comment_author_url, $comment_id, $comment );
     384        return apply_filters( 'get_comment_author_url', $comment_author_url, $comment_id, $comment ); 
    370385}
    371386
    372387/**
     
    381396function comment_author_url( $comment_id = 0 ) {
    382397        $comment = get_comment( $comment_id );
    383398
    384         $comment_author_url = get_comment_author_url( $comment );
     399        $comment_author_url = $comment ? get_comment_author_url( $comment ) : '';
     400
     401        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    385402
    386403        /**
    387404         * Filters the comment author's URL for display.
     
    392409         * @param string $comment_author_url The comment author's URL.
    393410         * @param string $comment_id         The comment ID as a numeric string.
    394411         */
    395         echo apply_filters( 'comment_url', $comment_author_url, $comment->comment_ID );
     412        echo apply_filters( 'comment_url', $comment_author_url, $comment_id );
    396413}
    397414
    398415/**
     
    421438function get_comment_author_url_link( $link_text = '', $before = '', $after = '', $comment = 0 ) {
    422439        $comment_author_url = get_comment_author_url( $comment );
    423440
    424         $display = ( '' !== $link_text ) ? $link_text : $comment_author_url;
     441        $display = $link_text ? $link_text : $comment_author_url;
    425442        $display = str_replace( 'http://www.', '', $display );
    426443        $display = str_replace( 'http://', '', $display );
    427444
     
    603620
    604621        $_format = ! empty( $format ) ? $format : get_option( 'date_format' );
    605622
    606         $comment_date = mysql2date( $_format, $comment->comment_date );
     623        $comment_date = $comment ? mysql2date( $_format, $comment->comment_date ) : '';
    607624
    608625        /**
    609626         * Filters the returned comment date.
    610627         *
    611628         * @since 1.5.0
    612629         *
    613          * @param string|int $comment_date Formatted date string or Unix timestamp.
    614          * @param string     $format       PHP date format.
    615          * @param WP_Comment $comment      The comment object.
     630         * @param string|int      $comment_date Formatted date string or Unix timestamp.
     631         * @param string          $format       PHP date format.
     632         * @param WP_Comment|null $comment      The comment object.
    616633         */
    617634        return apply_filters( 'get_comment_date', $comment_date, $format, $comment );
    618635}
     
    646663function get_comment_excerpt( $comment_id = 0 ) {
    647664        $comment = get_comment( $comment_id );
    648665
     666        $comment_text = $comment ? $comment->comment_content : '';
     667
     668        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
     669
    649670        if ( ! post_password_required( $comment->comment_post_ID ) ) {
    650                 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
     671                $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment_text ) );
    651672        } else {
    652673                $comment_text = __( 'Password protected' );
    653674        }
     
    672693         * @since 1.5.0
    673694         * @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
    674695         *
    675          * @param string     $comment_excerpt The comment excerpt text.
    676          * @param string     $comment_id      The comment ID as a numeric string.
    677          * @param WP_Comment $comment         The comment object.
     696         * @param string          $comment_excerpt The comment excerpt text.
     697         * @param string          $comment_id      The comment ID as a numeric string.
     698         * @param WP_Comment|null $comment         The comment object.
    678699         */
    679         return apply_filters( 'get_comment_excerpt', $comment_excerpt, $comment->comment_ID, $comment );
     700        return apply_filters( 'get_comment_excerpt', $comment_excerpt, $comment_id, $comment );
    680701}
    681702
    682703/**
     
    691712function comment_excerpt( $comment_id = 0 ) {
    692713        $comment = get_comment( $comment_id );
    693714
    694         $comment_excerpt = get_comment_excerpt( $comment );
     715        $comment_excerpt = $comment ? get_comment_excerpt( $comment ) : '';
     716
     717        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    695718
    696719        /**
    697720         * Filters the comment excerpt for display.
     
    702725         * @param string $comment_excerpt The comment excerpt text.
    703726         * @param string $comment_id      The comment ID as a numeric string.
    704727         */
    705         echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
     728        echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_id );
    706729}
    707730
    708731/**
     
    715738function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    716739        $comment = get_comment();
    717740
    718         $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0';
     741        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0'; 
    719742
    720743        /**
    721744         * Filters the returned comment ID.
     
    723746         * @since 1.5.0
    724747         * @since 4.1.0 The `$comment` parameter was added.
    725748         *
    726          * @param string     $comment_id The current comment ID as a numeric string.
    727          * @param WP_Comment $comment    The comment object.
     749         * @param string          $comment_id The current comment ID as a numeric string.
     750         * @param WP_Comment|null $comment    The comment object.
    728751         */
    729752        return apply_filters( 'get_comment_ID', $comment_id, $comment );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    730753}
     
    783806
    784807        $args = wp_parse_args( $args, $defaults );
    785808
    786         $comment_link = get_permalink( $comment->comment_post_ID );
     809        $comment_link = $comment ? get_permalink( $comment->comment_post_ID ) : '';
    787810
    788811        // The 'cpage' param takes precedence.
    789812        if ( ! is_null( $args['cpage'] ) ) {
     
    807830                                $cpage = get_query_var( 'cpage' );
    808831                        } else {
    809832                                // Requires a database hit, so we only do it when we can't figure out from context.
    810                                 $cpage = get_page_of_comment( $comment->comment_ID, $args );
     833                                $cpage = $comment ? get_page_of_comment( $comment->comment_ID, $args ) : 0;
    811834                        }
    812835                }
    813836
     
    836859                $comment_link = user_trailingslashit( $comment_link, 'comment' );
    837860        }
    838861
    839         $comment_link = $comment_link . '#comment-' . $comment->comment_ID;
     862        $comment_link = ( $comment_link ) ? $comment_link . '#comment-' . $comment->comment_ID : '';
    840863
    841864        /**
    842865         * Filters the returned single comment permalink.
     
    846869         *
    847870         * @see get_page_of_comment()
    848871         *
    849          * @param string     $comment_link The comment permalink with '#comment-$id' appended.
    850          * @param WP_Comment $comment      The current comment object.
    851          * @param array      $args         An array of arguments to override the defaults.
    852          * @param int        $cpage        The calculated 'cpage' value.
     872         * @param string          $comment_link The comment permalink with '#comment-$id' appended.
     873         * @param WP_Comment|null $comment      The current comment object.
     874         * @param array           $args         An array of arguments to override the defaults.
     875         * @param int             $cpage        The calculated 'cpage' value.
    853876         */
    854877        return apply_filters( 'get_comment_link', $comment_link, $comment, $args, $cpage );
    855878}
     
    10211044function get_comment_text( $comment_id = 0, $args = array() ) {
    10221045        $comment = get_comment( $comment_id );
    10231046
    1024         $comment_text = $comment->comment_content;
     1047        $comment_text = $comment ? $comment->comment_content : '';
    10251048
    1026         if ( is_comment_feed() && $comment->comment_parent ) {
     1049        if ( is_comment_feed() && ! empty( $comment->comment_parent ) ) {
    10271050                $parent = get_comment( $comment->comment_parent );
    10281051                if ( $parent ) {
    10291052                        $parent_link = esc_url( get_comment_link( $parent ) );
     
    10441067         *
    10451068         * @see Walker_Comment::comment()
    10461069         *
    1047          * @param string     $comment_text Text of the comment.
    1048          * @param WP_Comment $comment      The comment object.
    1049          * @param array      $args         An array of arguments.
     1070         * @param string          $comment_text Text of the comment.
     1071         * @param WP_Comment|null $comment      The comment object.
     1072         * @param array           $args         An array of arguments.
    10501073         */
    10511074        return apply_filters( 'get_comment_text', $comment_text, $comment, $args );
    10521075}
     
    10661089function comment_text( $comment_id = 0, $args = array() ) {
    10671090        $comment = get_comment( $comment_id );
    10681091
    1069         $comment_text = get_comment_text( $comment, $args );
     1092        $comment_text = $comment ? get_comment_text( $comment, $args ) : '';
    10701093
    10711094        /**
    10721095         * Filters the text of a comment to be displayed.
     
    10991122function get_comment_time( $format = '', $gmt = false, $translate = true, $comment_id = 0 ) {
    11001123        $comment = get_comment( $comment_id );
    11011124
    1102         if ( null === $comment ) {
    1103                 return '';
    1104         }
    1105 
    1106         $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
     1125       
     1126        if ( $comment ) {
     1127                $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
    11071128
    1108         $_format = ! empty( $format ) ? $format : get_option( 'time_format' );
     1129                $_format = ! empty( $format ) ? $format : get_option( 'time_format' );
    11091130
    1110         $comment_time = mysql2date( $_format, $comment_date, $translate );
     1131                $comment_time = mysql2date( $_format, $comment_date, $translate );
     1132        } else {
     1133                $comment_time = '';
     1134        }
    11111135
    11121136        /**
    11131137         * Filters the returned comment time.
    11141138         *
    11151139         * @since 1.5.0
    11161140         *
    1117          * @param string|int $comment_time The comment time, formatted as a date string or Unix timestamp.
    1118          * @param string     $format       PHP date format.
    1119          * @param bool       $gmt          Whether the GMT date is in use.
    1120          * @param bool       $translate    Whether the time is translated.
    1121          * @param WP_Comment $comment      The comment object.
     1141         * @param string|int      $comment_time The comment time, formatted as a date string or Unix timestamp.
     1142         * @param string          $format       PHP date format.
     1143         * @param bool            $gmt          Whether the GMT date is in use.
     1144         * @param bool            $translate    Whether the time is translated.
     1145         * @param WP_Comment|null $comment      The comment object.
    11221146         */
    11231147        return apply_filters( 'get_comment_time', $comment_time, $format, $gmt, $translate, $comment );
    11241148}
     
    11501174function get_comment_type( $comment_id = 0 ) {
    11511175        $comment = get_comment( $comment_id );
    11521176
    1153         if ( '' === $comment->comment_type ) {
    1154                 $comment->comment_type = 'comment';
    1155         }
     1177       
     1178        if ( $comment ) {
     1179                $comment_type = $comment->comment_type ? $comment->comment_type : 'comment';
     1180        } else {
     1181                $comment_type = '';
     1182        }
     1183
     1184        $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    11561185
    11571186        /**
    11581187         * Filters the returned comment type.
     
    11601189         * @since 1.5.0
    11611190         * @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
    11621191         *
    1163          * @param string     $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
    1164          * @param string     $comment_id   The comment ID as a numeric string.
    1165          * @param WP_Comment $comment      The comment object.
     1192         * @param string          $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. Empty string for non-existent comment.
     1193         * @param string          $comment_id   The comment ID as a numeric string.
     1194         * @param WP_Comment|null $comment      The comment object.
    11661195         */
    1167         return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
     1196        return apply_filters( 'get_comment_type', $comment_type, $comment_id, $comment );
    11681197}
    11691198
    11701199/**
     
    17631792
    17641793        $comment = get_comment( $comment );
    17651794
    1766         if ( empty( $comment ) ) {
    1767                 return;
    1768         }
    1769 
    1770         if ( empty( $post ) ) {
     1795        if ( ! $post && $comment ) {
    17711796                $post = $comment->comment_post_ID;
    17721797        }
    17731798
    17741799        $post = get_post( $post );
    17751800
    1776         if ( ! comments_open( $post->ID ) ) {
     1801        if ( $post && ! comments_open( $post->ID ) ) {
    17771802                return false;
    17781803        }
    17791804
    1780         if ( get_option( 'page_comments' ) ) {
    1781                 $permalink = str_replace( '#comment-' . $comment->comment_ID, '', get_comment_link( $comment ) );
    1782         } else {
    1783                 $permalink = get_permalink( $post->ID );
    1784         }
    1785 
    17861805        /**
    17871806         * Filters the comment reply link arguments.
    17881807         *
    17891808         * @since 4.1.0
    17901809         *
    1791          * @param array      $args    Comment reply link arguments. See get_comment_reply_link()
    1792          *                            for more information on accepted arguments.
    1793          * @param WP_Comment $comment The object of the comment being replied to.
    1794          * @param WP_Post    $post    The WP_Post object.
     1810         * @param array           $args    Comment reply link arguments. See get_comment_reply_link()
     1811         *                                 for more information on accepted arguments.
     1812         * @param WP_Comment|null $comment The object of the comment being replied to.
     1813         * @param WP_Post         $post    The WP_Post object.
    17951814         */
    17961815        $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
    17971816
     
    18011820                        esc_url( wp_login_url( get_permalink() ) ),
    18021821                        $args['login_text']
    18031822                );
    1804         } else {
     1823        } elseif ( $comment ) {
    18051824                $data_attributes = array(
    18061825                        'commentid'      => $comment->comment_ID,
    18071826                        'postid'         => $post->ID,
     
    18181837
    18191838                $data_attribute_string = trim( $data_attribute_string );
    18201839
     1840               
     1841                if ( get_option( 'page_comments' ) ) {
     1842                        $permalink = str_replace( '#comment-' . $comment->comment_ID, '', get_comment_link( $comment ) );
     1843                } else {
     1844                        $permalink = $post ? get_permalink( $post->ID ) : '';
     1845                }
     1846
    18211847                $link = sprintf(
    18221848                        "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
    18231849                        esc_url(
     
    18341860                        esc_attr( sprintf( $args['reply_to_text'], get_comment_author( $comment ) ) ),
    18351861                        $args['reply_text']
    18361862                );
    1837         }
     1863        } else {
     1864                $link = '';
     1865        }
    18381866
    18391867        $comment_reply_link = $args['before'] . $link . $args['after'];
    18401868
     
    18431871         *
    18441872         * @since 2.7.0
    18451873         *
    1846          * @param string     $comment_reply_link The HTML markup for the comment reply link.
    1847          * @param array      $args               An array of arguments overriding the defaults.
    1848          * @param WP_Comment $comment            The object of the comment being replied.
    1849          * @param WP_Post    $post               The WP_Post object.
     1874         * @param string          $comment_reply_link The HTML markup for the comment reply link.
     1875         * @param array           $args               An array of arguments overriding the defaults.
     1876         * @param WP_Comment|null $comment            The object of the comment being replied.
     1877         * @param WP_Post         $post               The WP_Post object.
    18501878         */
    18511879        return apply_filters( 'comment_reply_link', $comment_reply_link, $args, $comment, $post );
    18521880}
  • tests/phpunit/tests/comment/getCommentExcerpt.php

     
    2424                $this->assertCount( 20, explode( ' ', $excerpt ) );
    2525        }
    2626
     27        public function test_get_comment_excerpt_with_non_existing_id() {
     28                $comment_id = self::factory()->comment->create( array(
     29                        'comment_content' => self::$bacon_comment
     30                ) );
     31
     32                $this->assertEquals( '', get_comment_excerpt( -1 ) );
     33        }
     34
    2735        public function test_get_comment_excerpt_filtered() {
    2836                $comment_id = self::factory()->comment->create(
    2937                        array(
  • tests/phpunit/tests/comment/getCommentReplyLink.php

     
    7272        /**
    7373         * @ticket 41846
    7474         */
    75         public function test_should_return_null_when_depth_less_than_max_depth_and_comment_null_and_no_current_global_comment() {
     75        public function test_should_return_empty_string_when_depth_less_than_max_depth_and_comment_null_and_no_current_global_comment() {
    7676
    7777                // Let max depth be greater than depth and depth be non-zero.
    7878                $args = array(
     
    8585
    8686                $actual = get_comment_reply_link( $args );
    8787
    88                 $this->assertNull( $actual );
     88                $this->assertEquals( '', $actual );
    8989        }
    9090}