Skip to content

Conversation

@adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Oct 23, 2025

Trac ticket: https://core.trac.wordpress.org/ticket/64145
Also fixes: https://core.trac.wordpress.org/ticket/64152

Fixes WordPress/gutenberg#72548.
Fixes WordPress/gutenberg#72607.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Oct 23, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adamsilverstein, westonruter, timothyblynjacobs, shailu25, peterwilsoncc, mamaduka, wildworks, jeffpaul, swissspidy, threadi.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@TimothyBJacobs
Copy link
Member

This seems like the best and safest solution to me. The phpdoc needs to be updated to mention the new 'all' value.

@adamsilverstein
Copy link
Member Author

The phpdoc needs to be updated to mention the new 'all' value.

Updated in 35aa672

@adamsilverstein
Copy link
Member Author

I added some unit tests with assistance from Claude Code in d556331

@Mamaduka
Copy link
Member

@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:

public function test_get_comment_with_children_link() {
$comment_id_1 = self::factory()->comment->create(
array(
'comment_approved' => 1,
'comment_post_ID' => self::$post_id,
'user_id' => self::$subscriber_id,
)
);
$child_comment = self::factory()->comment->create(
array(
'comment_approved' => 1,
'comment_parent' => $comment_id_1,
'comment_post_ID' => self::$post_id,
'user_id' => self::$subscriber_id,
)
);
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 200, $response->get_status() );
$this->assertArrayHasKey( 'children', $response->get_links() );
}

@adamsilverstein
Copy link
Member Author

do you mind adding the children link test for notes in the comments controller?

Will do!

@adamsilverstein
Copy link
Member Author

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.

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: 82fbb38

@adamsilverstein
Copy link
Member Author

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.

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: 82fbb38

I was able to fix the test failures which I believe are legitimate with this commit: f980a6c

I'm going to cherry pick the test and fix to a new PR since it is a separate issue

@adamsilverstein
Copy link
Member Author

I'm going to cherry pick the test and fix to a new PR since it is a separate issue

#10420

Will open matching Trac ticket

@peterwilsoncc
Copy link
Contributor

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;

array(
'count' => true,
'orderby' => 'none',
'type' => 'all',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: before this change, not passing a type implied 'all'

@adamsilverstein
Copy link
Member Author

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
Copy link
Member Author

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.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I don't have all of the context.

@Mamaduka
Copy link
Member

@adamsilverstein, do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned children link won't do anything.

@adamsilverstein
Copy link
Member Author

do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned children link won't do anything.

Yes, I will work on adding that!

@adamsilverstein
Copy link
Member Author

do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned children link won't do anything.

Yes, I will work on adding that!

Added in 63e391d. I am going to add a test for this.

@adamsilverstein
Copy link
Member Author

do you mind including the fix from WordPress/gutenberg#72561? Otherwise, the returned children link 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 5c08331

I also validated the fix using the testing instructions in WordPress/gutenberg#72561

@adamsilverstein
Copy link
Member Author

@Mamaduka can you please review the additional changes and test for children embedding? then I can get this committed.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @adamsilverstein!

I left one note regarding tests, but the children backport looks good.

@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61105
GitHub commit: dac5fa8

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Oct 31, 2025
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61105
GitHub commit: dac5fa8

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes appearing on site frontend and as Recent Comments on Dashboard Block Notes: Number of my own comments increases

6 participants