Skip to content

Commit 141982e

Browse files
Fix get_comment function to return null for invalid WP_Comment instances
1 parent 9560368 commit 141982e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/wp-includes/comment.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,12 @@ function get_comment( $comment = null, $output = OBJECT ) {
240240
*
241241
* @since 2.3.0
242242
*
243-
* @param WP_Comment $_comment Comment data.
243+
* @param WP_Comment|null $_comment Comment data.
244244
*/
245245
$_comment = apply_filters( 'get_comment', $_comment );
246+
if ( ! ( $_comment instanceof WP_Comment ) ) {
247+
return null;
248+
}
246249

247250
if ( OBJECT === $output ) {
248251
return $_comment;

0 commit comments

Comments
 (0)