Commit 55ffbba205 for wordpress.org

commit 55ffbba2058470a27ba6c7c66d1c8b146729093c
Author: Weston Ruter <weston@xwp.co>
Date:   Thu Dec 11 01:55:35 2025 +0000

    Export: Update `export_wp()` to handle `get_comment()` returning `null` due to filter.

    The `get_comment` filter now explicitly documents returning `null` in addition to a `WP_Comment` object. This allows the filter to be used to exclude comments from an export. The `get_comment()` function already supported returning `null`.

    Developed in https://github.com/WordPress/wordpress-develop/pull/8383

    Props abcd95, WPExplorer, desrosj, mukesh27, westonruter, SirLouen, lbones, mdibrahimk48, audrasjb, jorbin, wildworks, hellofromTonya, saurabh.dhariwal, mabfahad.
    Fixes #61244.

    Built from https://develop.svn.wordpress.org/trunk@61369


    git-svn-id: http://core.svn.wordpress.org/trunk@60681 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php
index 9d5903a98c..4fe697e7e6 100644
--- a/wp-admin/includes/export.php
+++ b/wp-admin/includes/export.php
@@ -685,7 +685,12 @@ function export_wp( $args = array() ) {
 	endforeach;

 				$_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
-				$comments  = array_map( 'get_comment', $_comments );
+				$comments  = array_filter(
+					array_map( 'get_comment', $_comments ),
+					static function ( $comment ) {
+						return $comment instanceof WP_Comment;
+					}
+				);
 				foreach ( $comments as $c ) :
 					?>
 		<wp:comment>
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index 7ce4976523..bb4abf2cd7 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -240,9 +240,12 @@ function get_comment( $comment = null, $output = OBJECT ) {
 	 *
 	 * @since 2.3.0
 	 *
-	 * @param WP_Comment $_comment Comment data.
+	 * @param WP_Comment|null $_comment Comment data.
 	 */
 	$_comment = apply_filters( 'get_comment', $_comment );
+	if ( ! ( $_comment instanceof WP_Comment ) ) {
+		return null;
+	}

 	if ( OBJECT === $output ) {
 		return $_comment;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 86bdace909..f155e244c2 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.0-alpha-61368';
+$wp_version = '7.0-alpha-61369';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.