Verbum Comments: prevent duplicate comment submissions - #51045
Verbum Comments: prevent duplicate comment submissions#51045arcangelini wants to merge 1 commit into
Conversation
Guard the comment form's submit event so a second submission cannot start while one is in flight, and stop re-posting the form after the request has already reached wp-comments-post.php.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 2 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
Proposed changes
Readers were getting the same comment posted several times — byte-identical content, seconds apart. Verbum's only protection was the submit button's
disabledprop, and it leaked in a few ways.submitevent with a re-entrancy check that takes effect synchronously inside the handler, so repeat clicks (or implicit submission from the name/email inputs) can't start a second submission while one is in flight. The button'sdisabledprop was previously applied a macrotask late viasetTimeout( …, 0 ); three clicks in a single task all reached the server.wp-comments-post.php. The subscription-modal path calledHTMLFormElement.prototype.submit()on any non-redirect response — and re-enabled the button first — so one click could produce two submissions. The error branch had noreturn, so a rejected comment showed the error inline and sent a second POST.fetchused to leave the button stuck in its busy state with no message and no way to retry.pageshow+persisted), so navigating back to a post doesn't leave the comment form permanently locked.Worth noting for reviewers: WordPress's own duplicate-comment check in
wp_allow_comment()does not reliably reject these, so the client is currently the only thing standing between a reader and a duplicate.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Verbum only runs on WordPress.com Simple, so test on a Simple site with comments open to everyone.