[wp-trac] [WordPress Trac] #61244: The export_wp() function inserts empty <wp:comment> data when get_comment() returns a false or empty value
WordPress Trac
noreply at wordpress.org
Sat Nov 29 06:42:23 UTC 2025
#61244: The export_wp() function inserts empty <wp:comment> data when get_comment()
returns a false or empty value
-------------------------------------------------+-------------------------
Reporter: WPExplorer | Owner:
| westonruter
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 7.0
Component: Export | Version: 4.4
Severity: minor | Resolution:
Keywords: has-test-info has-patch needs- | Focuses:
testing changes-requested | administration
-------------------------------------------------+-------------------------
Changes (by westonruter):
* keywords: has-test-info has-patch needs-testing => has-test-info has-
patch needs-testing changes-requested
Comment:
As part of this, the `get_comment` filter should also be updated to
indicate that it can return `null` as well:
{{{#!diff
--- a/src/wp-includes/comment.php
+++ b/src/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;
}}}
Otherwise, if someone tries to return `null` (or `false`) in a callback to
the `get_comment` filter, then technically they are violating the filter's
allowed types.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61244#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list