Skip to content

Comments: Update the "Mine" count after AJAX moderation and reply actions. - #13040

Open
ikamal7 wants to merge 1 commit into
WordPress:trunkfrom
ikamal7:fix/46017-mine-comment-count
Open

Comments: Update the "Mine" count after AJAX moderation and reply actions.#13040
ikamal7 wants to merge 1 commit into
WordPress:trunkfrom
ikamal7:fix/46017-mine-comment-count

Conversation

@ikamal7

@ikamal7 ikamal7 commented Aug 13, 2026

Copy link
Copy Markdown

Summary

  • The comments list table updates the All, Approved, Pending, Spam, and Trash counts via AJAX after replying to or moderating a comment, but the "Mine" count never updates.
  • Adds an isCurrentUserComment flag to the supplemental data returned by _wp_ajax_delete_comment_response() (used by both wp_ajax_delete_comment() for trash/untrash/spam/unspam/delete, and wp_ajax_dim_comment() for approve/unapprove).
  • edit-comments.js uses that flag to bump span.mine-count by the same delta as Pending/Approved when the affected comment belongs to the current user, and unconditionally bumps it by 1 after a reply is added (a reply is always authored by the current user).

Why

"Mine" (class-wp-comments-list-table.php) counts comments where comment->user_id === get_current_user_id(), independent of moderation. Approve/Unapprove alone never changes this count since Mine already includes both pending and approved comments; only entering/leaving Spam/Trash does — which is what the JS change reflects.

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

Testing

  • php -l on the touched PHP file.
  • node --check on the touched JS file.
  • Manually verified in the browser: replying to and moderating (approve/unapprove/spam/unspam/trash/untrash) a comment authored by the current user updates the "Mine" tab count; actions on other users' comments leave it unchanged.

Test plan

  • Visit /wp-admin/edit-comments.php as a user who has authored comments.
  • Reply to one of your own comments — "Mine" count increments.
  • Approve/Unapprove one of your own comments — "Mine" count stays the same (comment just moves between Pending/Approved).
  • Spam, Trash, and their Undo actions on your own comments — "Mine" count decrements/increments accordingly.
  • Moderate a comment authored by a different user — "Mine" count does not change.

…ions.

The comments list table updates the All, Approved, Pending, Spam, and
Trash counts via AJAX, but the Mine count never changed because the
moderation/reply responses did not indicate whether the affected
comment belonged to the current user. Adds an isCurrentUserComment
flag to the AJAX supplemental data and uses it in edit-comments.js to
keep the Mine count in sync.

Props itzmekhokan, peterwilsoncc, arkaprabhachowdhury.
Fixes #46017
@github-actions

Copy link
Copy Markdown

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

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

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

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.

1 participant