#64145 closed defect (bug) (fixed)
Notes should not appear in the context of comments
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | high |
| Severity: | normal | Version: | 6.9 |
| Component: | Notes | Keywords: | has-patch dev-feedback has-unit-tests commit has-dev-note |
| Focuses: | Cc: |
Description
Notes should never appear in the context of regular (front end) comments. Although they share the same comments table, notes use a specific "note" comment type. Notes of this type need to be consistently excluded wherever comments or comment counts are shown.
Related reports in the Gutenberg repository:
- Showing in recent comments widget: https://github.com/WordPress/gutenberg/issues/72607
- Showing in "Mine" count: https://github.com/WordPress/gutenberg/issues/72548
Feedback from @mamaduka:
This happens only in WP 6.9 Beta when the Gutenberg plugin is not active. To reproduce the same issue with Gutenberg, you'll need to remove the exclude_block_comments_from_admin filter. During the core sync, it was decided not to use a similar filter and modify the admin comment list queries directly.
Problem
The Comment Query's default value for type is an empty string, which means all types are returned. We'll have to modify this logic in a backward-compatible manner, maybe giving it a different meaning - all types except note.
Unfortunately, I'm not sure what the best way to do it is. Hardcode it, use a filter like we do in Gutenberg, or something else.
From @jeffpaul:
Note that this was also reported in https://wordpress.org/support/topic/showing-new-notes-under-recent-comments-in-dashboard-is-tricky/#post-18691377.
Change History (33)
This ticket was mentioned in PR #10405 on WordPress/wordpress-develop by @adamsilverstein.
5 months ago
#1
- Keywords has-patch added; needs-patch removed
#2
@
5 months ago
- Keywords dev-feedback needs-testing added
I have posted a proposed solution that excludes the notes type at the WP_Comment_Query level (unless 'note' or 'all' is explicitly requested). This fixes all of the comment context issues, so I was also able to remove two instances where we added 'note' exclusions that are no longer required.
@TimothyBlynJacobs commented on PR #10405:
5 months ago
#4
This seems like the best and safest solution to me. The phpdoc needs to be updated to mention the new 'all' value.
@adamsilverstein commented on PR #10405:
5 months ago
#5
The phpdoc needs to be updated to mention the new 'all' value.
Updated in 35aa672b5ab05b2cdc035b2adf57329423edc9d6
@adamsilverstein commented on PR #10405:
5 months ago
#6
I added some unit tests with assistance from Claude Code in https://github.com/WordPress/wordpress-develop/pull/10405/commits/d556331319f10f972f5ff82c2d5fa7679c59c5bf
@Mamaduka commented on PR #10405:
5 months ago
#7
@adamsilverstein, do you mind adding the children link test for notes in the comments controller? Asking because we had an issue with the filter used in Gutenberg.
We could copy the following test and adapt it for note:
@adamsilverstein commented on PR #10405:
5 months ago
#8
do you mind adding the children link test for notes in the comments controller?
Will do!
This ticket was mentioned in PR #10413 on WordPress/wordpress-develop by @adamsilverstein.
5 months ago
#9
- Keywords has-unit-tests added
Trac ticket:
@adamsilverstein commented on PR #10405:
5 months ago
#10
do you mind adding the
childrenlink test for notes in the comments controller? Asking because we had an issue with the filter used in Gutenberg.
I tried adding this test, but it fails: the response does not include the children attribute for notes. I'm not quite sure why yet: https://github.com/WordPress/wordpress-develop/pull/10413/commits/82fbb38835262d28ef533d149520f15e8d5492aa
@adamsilverstein commented on PR #10405:
5 months ago
#11
do you mind adding the
childrenlink test for notes in the comments controller? Asking because we had an issue with the filter used in Gutenberg.
I tried adding this test, but it fails: the response does not include the
childrenattribute for notes. I'm not quite sure why yet: 82fbb38
I was able to fix the test failures which I believe are legitimate with this commit: https://github.com/WordPress/wordpress-develop/pull/10413/commits/f980a6c4a0b5576166f9416d6441a18c90c183dc
I'm going to cherry pick the test and fix to a new PR since it is a separate issue
@adamsilverstein commented on PR #10405:
5 months ago
#12
I'm going to cherry pick the test and fix to a new PR since it is a separate issue
https://github.com/WordPress/wordpress-develop/pull/10420
Will open matching Trac ticket
@peterwilsoncc commented on PR #10405:
5 months ago
#13
I'm wondering if it's worth introducing a meta capability for read_comment that maps to edit_post for notes, in map_meta_cap it would look something like this:
case 'read_comment':
if ( ! isset( $args[0] ) ) {
/* translators: %s: Capability name. */
$message = __( 'When checking for the %s capability, you must always check it against a specific comment.' );
_doing_it_wrong(
__FUNCTION__,
sprintf( $message, '<code>' . $cap . '</code>' ),
'6.9.0'
);
$caps[] = 'do_not_allow';
break;
}
$comment = get_comment( $args[0] );
if ( ! $comment ) {
$caps[] = 'do_not_allow';
break;
}
$comment_type = get_comment_type( $comment );
$post_id = $comment->comment_post_ID;
if ( 'note' === $comment_type ) {
// Comment is a note, requires edit_post capability.
$caps = map_meta_cap( 'edit_post', $user_id, $post_id );
}
break;
@adamsilverstein commented on PR #10405:
4 months ago
#14
I'm wondering if it's worth introducing a meta capability for read_comment that maps to edit_post for notes, in map_meta_cap it would look something like this:
@peterwilsoncc that sounds great, can we work on it in a separate PR as it feels unrelated to the current change?
@adamsilverstein commented on PR #10405:
4 months ago
#15
This seems like the best and safest solution to me. The phpdoc needs to be updated to mention the new 'all' value.
@TimothyBJacobs I updated the docblock, thanks for reviewing.
@adamsilverstein commented on PR #10405:
4 months ago
#16
@adamsilverstein, do you mind adding the children link test for notes in the comments controller? Asking because we had an issue with the filter used in Gutenberg.
@Mamaduka this is now included, along with the related fix.
#17
@
4 months ago
The attached PR now includes the children fix and test as well. See https://core.trac.wordpress.org/ticket/64152 which is was being caused by this PR.
@adamsilverstein commented on PR #10405:
4 months ago
#18
@westonruter Thanks for your review. All feedback has been addressed, can you please give it another pass?
#20
@
4 months ago
- Keywords commit added; needs-testing removed
Awaiting final review - then this should be ready to commit.
@Mamaduka commented on PR #10405:
4 months ago
#22
@adamsilverstein, do you mind including the fix from https://github.com/WordPress/gutenberg/pull/72561? Otherwise, the returned children link won't do anything.
#23
@
4 months ago
We're effectively talking about the need to make a comment_type private. How big a deal is it to enable this for comment types beyond just this new note type?
I'm currently working on something which will rely heavily on a private comment type. Rather than hacking my own custom 'exclude my comment type' solution, it would be great if I could just add_filter (or something) to graft my own comment type alongside note, and thus benefit from the same core-backed privacy.
@adamsilverstein commented on PR #10405:
4 months ago
#24
do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned
childrenlink won't do anything.
Yes, I will work on adding that!
@adamsilverstein commented on PR #10405:
4 months ago
#25
do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned
childrenlink won't do anything.
Yes, I will work on adding that!
Added in 63e391d1f7355345f529b0dae5c21f40fc7d2400. I am going to add a test for this.
@adamsilverstein commented on PR #10405:
4 months ago
#26
do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned
childrenlink won't do anything.
Yes, I will work on adding that!
Added in 63e391d. I am going to add a test for this.
Added a test that verifies the query parameters are present in the children href in 5c083319592e1c4161b438408859d4f9bd61a4d7
I also validated the fix using the testing instructions in https://github.com/WordPress/gutenberg/pull/72561
@adamsilverstein commented on PR #10405:
4 months ago
#27
@Mamaduka can you please review the additional changes and test for children embedding? then I can get this committed.
#30
@
4 months ago
@adamsilverstein if there's a follow-up needed here, then let's please ensure we credit @burnuser and @shsajalchowdhury as original reporters from https://github.com/WordPress/gutenberg/issues/72607 in https://wordpress.org/support/topic/showing-new-notes-under-recent-comments-in-dashboard-is-tricky/#post-18691377. Otherwise, let's use the Core Props tool in Make/Core admin to add those two to the commit on this ticket.
#32
@
4 months ago
- Component changed from Editor to Notes
Moving tickets related to the new Notes feature into the new Notes sub-component under Comments.
#33
@
4 months ago
- Keywords has-dev-note added; needs-dev-note removed
Dev Note was published: https://make.wordpress.org/core/2025/11/15/notes-feature-in-wordpress-6-9/
Trac ticket: https://core.trac.wordpress.org/ticket/64145