Changeset 46335 – WordPress Trac (original) (raw)

Timestamp:

09/27/2019 02:45:49 PM (6 years ago)

whyisjake

Message:

Comments: Avoid PHP notice in get_comment_reply_link() for null comment.

If there is no global comment, or the input comment is null, return early to prevent warnings.

Fixes #41846
Props birgire, earnjam

Location:

trunk

Files:

Legend:

Unmodified

Added

Removed

r46090 r46335
1646 1646
1647 1647 comment=getcomment(comment = get_comment( comment=getcomment(comment );
1648
1649 if ( empty( $comment ) ) {
1650 return;
1651 }
1648 1652
1649 1653 if ( empty( $post ) ) {
r45787 r46335
67 67 this−>assertContains(this->assertContains( this>assertContains(expected_url, $comment_reply_link );
68 68 }
69
70 /**
71 * @ticket 41846
72 */
73 public function test_should_return_null_when_depth_less_than_max_depth_and_comment_null_and_no_current_global_comment() {
74
75 // Let max depth be greater than depth and depth be non-zero.
76 $args = array(
77 'depth' => 1,
78 'max_depth' => 2,
79 );
80
81 // Make sure there's no global comment object.
82 add_filter( 'get_comment', '__return_null' );
83
84 actual=getcommentreplylink(actual = get_comment_reply_link( actual=getcommentreplylink(args );
85
86 this−>assertNull(this->assertNull( this>assertNull(actual );
87 }
88
69 89 }

Note: See TracChangeset for help on using the changeset viewer.