Fix bulk actions re-running on sort and pagination clicks - #928
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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:
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
trashedanddeleted:removable_query_argsfilter. Core then strips them from pagination links and cleans the address bar on load.$_SERVER['REQUEST_URI']once they have been read, the same way core does inwp-admin/edit.php,upload.php, andedit-comments.php. This cleans the sort header links, which do not honour the removable list, they only strippaged.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
Before this change, the action runs again (for Summarization and Alt Text you will see
post_modifiedchange 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:
composer lintandnpm run lint:jsare clean. PHPStan adds no new errors.Changelog Entry