-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fast follow: Ensure block comments filter does not affect subsequent queries #71728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
andrewserong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure the least I could do after commenting is to take this PR for a spin!
This is testing well for me and looks like a good logical change to filter pre_get_comments rather than dealing with the SQL query 👍
✅ Querying get_comments or running wp comment list defaults to only showing actual comments, excluding block comments
✅ Calling get_comments with block_comment type reveals just the block comments
✅ Test coverage looks good
LGTM! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterwilsoncc, I think we don't need to prepare a core backport PR, as this feature is still experimental.
Edit: Sorry, I was mistaken, the core backports only have unit tests, so that's fine.
| } | ||
|
|
||
| /** | ||
| * Test that block comments are not excluded when explicitly queried. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice to have: another test that confirms that query is unchanged when block comments are explicitly excluded (type__not_in).
|
@adamsilverstein Added in 265b4c2, is that what you were after? |
|
Looks good, thanks @peterwilsoncc! |
|
Can we merge this PR? |
|
I was working on a different issue and noticed that the The |
|
Thanks George, the filter might need to bypass the changes if the parent ID
is set.
I'm on leave at the moment so won't get to it until next week. I'm happy if
someone wants to push to this branch.
|
|
Thanks for the pointer, @peterwilsoncc! I pushed the changes for the Now response returns the correct link for the This is due to the default collection values for these arguments. We'll probably have to make changes there without breaking backward compatibility. That's outside of the scope here. // Children embed URL, that doesn't work.
wp.data.select( 'core' ).getEntityRecords( 'root', 'comment', {
parent: 240,
} )
// Modified query that works.
wp.data.select( 'core' ).getEntityRecords( 'root', 'comment', {
type: 'block_comment',
status: 'all',
parent: 240,
} ) |
lib/experimental/block-comments.php
Outdated
| $types_not_in = array_filter( $types_not_in ); | ||
|
|
||
| // If 'block_comment' is already included in the types to include or exclude, do nothing. | ||
| if ( in_array( 'block_comment', array_merge( $types_in, $types_not_in ), true ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment type was changed to match the final feature name. Ref: ##72310.
|
Based on this feedback, we added Can we apply a similar approach to this PR? In other words, we should be able to use the |
@Mamaduka You're right. Additionally, there appear to be other items that need to be addressed. cc @swissspidy
|
In the core backport PR, I was able to address this issue by adding a However, the query parameters of the |
|
As I understand it, this PR is an improvement for the Gutenberg plugin and does not affect the core, so I will remove the @peterwilsoncc @adamsilverstein I have resolved the conflicts for now, but I would like to confirm whether this PR is still valid. |
|
This is an issue within the Gutenberg plugin, so let's address it in a point update. |
|
The plugin-specific issues don't have to be in WP-specific milestones. |
|
@Mamaduka reminder ping on this PR as something impacting the Gutenberg plugin specifically (i.e. not needed for WP 6.9 as not impacting WP Core) |


What?
Follow up to earlier PR fixing this bug to do the filtering on the
pre_get_commentsfilter.This is preferable than messing around with the database WHERE clause directly.
I've also added a bunch of unit tests to ensure that the code is working as expected.
Closes #71711
Follow up to #71712
Why?
Messing around with the database query clauses is flakier than using the query variables.
How?
Moves the changes back to the previous hook.
Testing Instructions
wp shell, replacing the post ID with the ID created aboveTesting Instructions for Keyboard
N/A
Screenshots or screencast
N/A