[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
Tue Sep 17 23:44:04 UTC 2024


#61244: The export_wp() function inserts empty <wp:comment> data when get_comment()
returns a false or empty value
-------------------------------------+-----------------------------
 Reporter:  WPExplorer               |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  6.7
Component:  Export                   |     Version:  4.4
 Severity:  minor                    |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  administration
-------------------------------------+-----------------------------

Comment (by lbones):

 Initially, I thought that the issue was that the comments were coming
 through whether or not they contained content. I realized upon further
 investigation that the issue, is if the person wants to run

 {{{
 add_action( 'export_wp', function() {
     add_filter( 'get_comment', '__return_false' );
 } );
 }}}

 then the patch, which contains an `array_filter` does work. Recommendation
 would be to add an export option without comments instead of the current
 patch.


 Reasoning: This very niche solution makes the entire get_comment call in
 the wp_export function slower. The array_filter in combination with
 `array_map` creates two maps (could probably have a map_reduce like
 function), and with the for loop, we are going through all of the comments
 thrice.

 P.S. I plan on opening a new ticket with the commenting editing issue I
 found. I believe the checks on modify_item in the comment controller just
 needs to be a little more robust.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61244#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list