Skip to content

Restrict note editing capabilities to their authors or comment moderators#11191

Open
mindctrl wants to merge 2 commits intoWordPress:trunkfrom
mindctrl:trac-64779/note-capabilities
Open

Restrict note editing capabilities to their authors or comment moderators#11191
mindctrl wants to merge 2 commits intoWordPress:trunkfrom
mindctrl:trac-64779/note-capabilities

Conversation

@mindctrl
Copy link

@mindctrl mindctrl commented Mar 6, 2026

Notes (internal collaborative comments on posts) currently inherit the same capability mapping as regular comments, meaning anyone who can edit the parent post can edit or delete any note on it.

Trac ticket: https://core.trac.wordpress.org/ticket/64779

Use of AI Tools

Opus 4.6 helped with this, particularly the phpunit tests.


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 Mar 6, 2026

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 mindctrl.

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

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

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

  • 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.

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.

Just some notes nits

}

/*
* Notes can be read by any user who can edit the parent post.
Copy link
Member

Choose a reason for hiding this comment

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

Minor point: I don't think “parent” is right to mention here, since it could be confused with comment_parent in that a comment can have a parent comment.

Suggested change
* Notes can be read by any user who can edit the parent post.
* Notes can be read by any user who can edit the associated post.

Comment on lines +579 to +580
*
* @since 7.0.0
Copy link
Member

Choose a reason for hiding this comment

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

Since this isn't a dockblock, a @since tag I don't think is warranted. I don't see other examples of this in the function.

Suggested change
*
* @since 7.0.0

*
* @ticket 64779
*/
public function test_contributor_cannot_update_others_note() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_contributor_cannot_update_others_note() {
public function test_contributor_cannot_update_others_note(): void {

*
* @ticket 64779
*/
public function test_contributor_cannot_delete_others_note() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_contributor_cannot_delete_others_note() {
public function test_contributor_cannot_delete_others_note(): void {

*
* @ticket 64779
*/
public function test_editor_can_update_others_note() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_editor_can_update_others_note() {
public function test_editor_can_update_others_note(): void {

* @ticket 64779
* @covers ::map_meta_cap
*/
public function test_delete_regular_comment_maps_to_edit_post() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_delete_regular_comment_maps_to_edit_post() {
public function test_delete_regular_comment_maps_to_edit_post(): void {

* @ticket 64779
* @covers ::map_meta_cap
*/
public function test_edit_comment_nonexistent_comment() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_edit_comment_nonexistent_comment() {
public function test_edit_comment_nonexistent_comment(): void {

* @ticket 64779
* @covers ::map_meta_cap
*/
public function test_delete_comment_nonexistent_comment() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_delete_comment_nonexistent_comment() {
public function test_delete_comment_nonexistent_comment(): void {

* @covers ::map_meta_cap
* @expectedIncorrectUsage map_meta_cap
*/
public function test_edit_comment_without_argument() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_edit_comment_without_argument() {
public function test_edit_comment_without_argument(): void {

* @covers ::map_meta_cap
* @expectedIncorrectUsage map_meta_cap
*/
public function test_delete_comment_without_argument() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function test_delete_comment_without_argument() {
public function test_delete_comment_without_argument(): void {

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.

2 participants