diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
index ca0a8de714..6ddca706bb 100644
|
|
|
function get_comment_reply_link( $args = array(), $comment = null, $post = null |
| 1641 | 1641 | |
| 1642 | 1642 | $comment = get_comment( $comment ); |
| 1643 | 1643 | |
| | 1644 | if ( empty( $comment ) ) { |
| | 1645 | return; |
| | 1646 | } |
| | 1647 | |
| 1644 | 1648 | if ( empty( $post ) ) { |
| 1645 | 1649 | $post = $comment->comment_post_ID; |
| 1646 | 1650 | } |
diff --git tests/phpunit/tests/comment/getCommentReplyLink.php tests/phpunit/tests/comment/getCommentReplyLink.php
index a9645fc4aa..a474077f7f 100644
|
|
|
class Tests_Comment_GetCommentReplyLink extends WP_UnitTestCase { |
| 26 | 26 | |
| 27 | 27 | $this->assertNull( get_comment_reply_link( $args ) ); |
| 28 | 28 | } |
| | 29 | |
| | 30 | /** |
| | 31 | * @ticket 41846 |
| | 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 | |
| 29 | 55 | } |