Opened 5 months ago
Last modified 4 weeks ago
#61244 new defect (bug)
The export_wp() function inserts empty <wp:comment> data when get_comment() returns a false or empty value
Reported by: | WPExplorer | Owned by: | |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | minor | Version: | 4.4 |
Component: | Export | Keywords: | has-patch needs-testing |
Focuses: | administration | Cc: |
Description
If you wish to exclude comments from the WordPress export you can use the following code:
add_action( 'export_wp', function() { add_filter( 'get_comment', '__return_false' ); } );
However, the function will still loop through empty values for the $comments array inserting unnecessary <wp:comment> items.
Attachments (2)
Change History (7)
This ticket was mentioned in PR #6574 on WordPress/wordpress-develop by @WPExplorer.
5 months ago
#1
- Keywords has-patch added
#2
@
5 months ago
- Focuses administration added
Hi @wpexplorer! 👋
Thank you for your contribution to WordPress! 💖
#3
@
6 weeks ago
- Keywords needs-testing added
- Milestone changed from Awaiting Review to 6.7
- Version changed from 6.6 to 4.4
While scrubbing for 6.6.x minor, dove into which WordPress Version introduced this bug and code. It was in WP 4.4 via [33891].
As it has a clear explanation and patch, moving it into 6.7 cycle for possible resolution.
#4
@
4 weeks ago
I am working on testing this one! I am planning on recreating the issue in WP 6.6., and then running the patch to verify if the issue has been resolved. I am using the WordPress Playground, but can test through the CLI or whatever you may need.
In the PlayGround, I did notice that the user is not able to enter an empty comment. To recreate, I wrote a comment, and then went into the WordPress editor and removed the text in the comment.
@
4 weeks ago
This is the test that was done using the patch [from PR=6574] which was PHP 8.2 and WP 6.6.2
#5
@
4 weeks ago
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.
If you wish to exclude comments from the WordPress export you can use the following code:
However, the function will still loop through empty values for the $comments array inserting unnecessary <wp:comment> items.