Skip to content

Commit 9560368

Browse files
Refactor comment filtering in export_wp function to ensure only valid WP_Comment instances are included
1 parent 834aad6 commit 9560368

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wp-admin/includes/export.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,12 @@ function wxr_filter_postmeta( $return_me, $meta_key ) {
685685
endforeach;
686686

687687
$_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
688-
$comments = array_filter( array_map( 'get_comment', $_comments ) );
688+
$comments = array_filter(
689+
array_map( 'get_comment', $_comments ),
690+
static function ( $comment ) {
691+
return $comment instanceof WP_Comment;
692+
}
693+
);
689694
foreach ( $comments as $c ) :
690695
?>
691696
<wp:comment>

0 commit comments

Comments
 (0)