Opened 9 months ago
Last modified 16 hours 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: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | minor | Version: | 4.4 |
Component: | Export | Keywords: | has-patch needs-testing has-unit-tests |
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 (13)
This ticket was mentioned in PR #6574 on WordPress/wordpress-develop by @WPExplorer.
9 months ago
#1
- Keywords has-patch added
#2
@
9 months ago
- Focuses administration added
Hi @wpexplorer! 👋
Thank you for your contribution to WordPress! 💖
#3
@
6 months 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
@
5 months 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.
@
5 months 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
@
5 months 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.
This ticket was mentioned in Slack in #core by stoyangeorgiev. View the logs.
4 months ago
#7
@
4 months ago
- Milestone changed from 6.7 to 6.8
This one was discussed at a bug-scrub. By the looks of it this one needs a bit more time, and with RC1 right around the corner, moving this one to 6.8. Cheers!
#8
@
2 months ago
Test Report:
The applied patch [PR=6574] shows no changes in functionality when tested with PHP 8.3 and WordPress 6.7.1.
Observation:
Attempting to submit an empty column does not work. However, when using the WordPress editor, removing text in a comment is possible without issues.
#9
@
5 days ago
- Keywords needs-unit-tests added
This looks good, but I'd love to see some unit tests that demonstrate the failure and confirming that the change fixes the issue.
This ticket was mentioned in PR #8383 on WordPress/wordpress-develop by @abcd95.
38 hours ago
#10
- Keywords has-unit-tests added; needs-unit-tests removed
Trac ticket: https://core.trac.wordpress.org/ticket/61244
This PR adds unit tests for the patch present to verify the behavior of comment filtering during exports.
The new test ensures that when comments are filtered out using get_comment
filter, no empty <wp:comment>
tags appear in the export XML.
Run the tests:
npm run test:php -- --filter=Tests_Admin_ExportWp
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.