Make WordPress Core

Ticket #41846: 41846.patch

File 41846.patch, 1.5 KB (added by birgire, 8 years ago)
  • src/wp-includes/comment-template.php

     
    16121612
    16131613        $comment = get_comment( $comment );
    16141614
     1615        if ( empty( $comment ) ) {
     1616                return;
     1617        }
     1618
    16151619        if ( empty( $post ) ) {
    16161620                $post = $comment->comment_post_ID;
    16171621        }
  • tests/phpunit/tests/comment/getCommentReplyLink.php

     
    2626
    2727                $this->assertNull( get_comment_reply_link( $args ) );
    2828        }
     29
     30        /**
     31         * @ticket
     32         */
     33        public function test_should_return_null_when_depth_less_than_max_depth_and_comment_null_and_no_current_global_comment() {
     34
     35                $args = array(
     36                        'depth'                 => 1,
     37                        'max_depth'             => 2,
     38                );
     39
     40                $comment = null;
     41
     42                // store current global comment
     43                $tmp = $GLOBALS['comment'];
     44
     45                // remove global current comment
     46                unset( $GLOBALS['comment'] );
     47               
     48                $this->assertFalse( isset( $GLOBALS['comment'] ) );
     49                $this->assertNull( get_comment_reply_link( $args ), $comment );
     50               
     51                // restore current global comment
     52                $GLOBALS['comment'] = $tmp;
     53        }
     54
    2955}