Skip to content

Fix bulk actions re-running on sort and pagination clicks - #928

Merged
dkotter merged 6 commits into
WordPress:developfrom
ekamran:sftq/fix-bulk-action-retrigger
Aug 11, 2026
Merged

Fix bulk actions re-running on sort and pagination clicks#928
dkotter merged 6 commits into
WordPress:developfrom
ekamran:sftq/fix-bulk-action-retrigger

Conversation

@ekamran

@ekamran ekamran commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What?

Bulk admin actions in three experiments re-run on every sort and pagination click after the action has finished. This fixes all three: Content Summarization, Alt Text Generation, and Comment Moderation.

Why?

Each bulk action puts a trigger param in the redirect URL, and the sort and pagination links the list table renders keep carrying that param. So the action fires again whenever the list is sorted or paginated:

  • Content Summarization (Posts list) re-generates summaries. This makes provider API calls and overwrites the summary blocks on every click.
  • Alt Text Generation (Media Library) re-generates alt text. Same cost.
  • Comment Moderation (Comments list) re-shows the "N comments queued" notice. This one is cosmetic, nothing is re-queued.

The first two cost money and overwrite user edits, so this is not just a visual issue.

How?

The same two part fix that core uses for its own one-shot params like trashed and deleted:

  1. Register the trigger params through the removable_query_args filter. Core then strips them from pagination links and cleans the address bar on load.
  2. Scrub the params from $_SERVER['REQUEST_URI'] once they have been read, the same way core does in wp-admin/edit.php, upload.php, and edit-comments.php. This cleans the sort header links, which do not honour the removable list, they only strip paged.

No JavaScript change is needed. The bulk scripts get their IDs from wp_localize_script, not from the URL. Comment Moderation reads its params from $_GET, which the scrub does not touch, so its notice still shows once on the redirect.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code (Anthropic)
Model(s): Claude
Used for: Investigating the bug, writing the fix, the unit tests, and the e2e tests, and running the full verification. I reviewed, tested, and take responsibility for all of it before submitting.

Testing Instructions

  1. Enable one of the three experiments with a configured provider.
  2. Have more than one page of items in the relevant list (Posts, Media in list mode, or Comments).
  3. Select some items, run the bulk action, and wait for the notice.
  4. Click a sortable column header or a pagination link.

Before this change, the action runs again (for Summarization and Alt Text you will see post_modified change and fresh provider calls; for Comment Moderation the notice re-appears). After this change, the list only sorts or paginates and nothing re-fires.

Automated coverage:

  • New integration tests for all three features. Each fails with its fix reverted.
  • New e2e tests for all three. Each checks the rendered sort link is clean and that sorting does not re-fire the action.
  • Full PHPUnit suite passes (1244 tests). composer lint and npm run lint:js are clean. PHPStan adds no new errors.

Changelog Entry

Fixed - Bulk actions (Generate Summary, Generate Alt Text, Analyze comments) no longer re-run when sorting or paginating the list after the action completes.

Open WordPress Playground Preview

@ekamran
ekamran requested a review from a team August 11, 2026 11:58
@github-actions

github-actions Bot commented Aug 11, 2026

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ekamran <ekamran@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

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

@ekamran ekamran changed the title Sftq/fix bulk action retrigger Fix bulk actions re-running on sort and pagination clicks Aug 11, 2026
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.95%. Comparing base (26356e9) to head (efbacc5).

Files with missing lines Patch % Lines
...eriments/Comment_Moderation/Comment_Moderation.php 87.50% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #928      +/-   ##
=============================================
+ Coverage      75.92%   75.95%   +0.02%     
- Complexity      2982     2989       +7     
=============================================
  Files            124      124              
  Lines          11832    11850      +18     
=============================================
+ Hits            8984     9001      +17     
- Misses          2848     2849       +1     
Flag Coverage Δ
unit 75.95% <94.44%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter added this to the 1.3.0 milestone Aug 11, 2026
@dkotter dkotter mentioned this pull request Aug 11, 2026
48 tasks
@dkotter
dkotter merged commit 4d52e02 into WordPress:develop Aug 11, 2026
24 checks passed
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

Sponsor
SponsoredKunjungi sekarang
Promo