Skip to content

Comments: Update the Mine count after AJAX actions#12620

Draft
ArkaPrabhaChowdhury wants to merge 2 commits into
WordPress:trunkfrom
ArkaPrabhaChowdhury:trac-46017-comment-mine-count
Draft

Comments: Update the Mine count after AJAX actions#12620
ArkaPrabhaChowdhury wants to merge 2 commits into
WordPress:trunkfrom
ArkaPrabhaChowdhury:trac-46017-comment-mine-count

Conversation

@ArkaPrabhaChowdhury

Copy link
Copy Markdown

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

Summary

  • Updates the "Mine" comment count after replying to a comment through AJAX.
  • Adds current-user ownership metadata to comment moderation AJAX responses.
  • Uses the existing approved and pending deltas to update "Mine" only when the affected comment belongs to the current user.
  • Adds regression coverage for the ownership metadata.

Why

The comments screen already updates the All, Pending, Approved, Spam, and Trash counts after AJAX actions, but it does not update Mine. Moderation responses also did not expose enough information for the client to know whether the affected comment belonged to the current user.

Testing

  • npm run test:php -- --group ajax --filter "Tests_Ajax_wpAjax(DeleteComment|DimComment|ReplytoComment)" (18 tests, 132 assertions)
  • npm run test:php -- --group ajax --filter Tests_Ajax_wpAjaxDeleteComment (6 tests, 85 assertions)
  • PHPCBF and PHPCS with phpcs.xml.dist on both touched PHP files
  • JavaScript JSHint passed for src/js/_enqueues/admin/edit-comments.js

Copilot AI review requested due to automatic review settings July 21, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the wp-admin Comments screen’s live counter updates by ensuring the “Mine” view count stays accurate after AJAX moderation and reply actions, using new server-provided metadata to determine whether a comment belongs to the current user.

Changes:

  • Adds supplemental.is_current_user to _wp_ajax_delete_comment_response() so the client can detect ownership.
  • Updates edit-comments.js to increment/decrement the “Mine” count after applicable AJAX actions.
  • Adds PHPUnit regression coverage verifying the new ownership metadata in the AJAX response.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/phpunit/tests/ajax/wpAjaxDeleteComment.php Adds a test asserting the AJAX response includes an ownership flag for current-user comments.
src/wp-admin/includes/ajax-actions.php Includes is_current_user ownership metadata in delete-comment AJAX responses.
src/js/_enqueues/admin/edit-comments.js Uses ownership metadata to update the “Mine” counter after moderation actions; increments “Mine” after replies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/js/_enqueues/admin/edit-comments.js Outdated
Comment on lines +626 to +628
if ( response.supplemental && 1 === parseInt( response.supplemental.is_current_user, 10 ) ) {
updateCountText( 'span.mine-count', ( pendingDiff || 0 ) + ( approvedDiff || 0 ) );
}
@github-actions

Copy link
Copy Markdown

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.

Copilot AI review requested due to automatic review settings July 21, 2026 07:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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