In a previous article, I wrote about how to use jQuery to remove submit form buttons and replacing it with some “Saving…” text to prevent duplicate form submissions.
Then what do you do?
Well I originally helped write a patch to prevent duplicate form submissions in Drupal 5 and it lived for a bit but was recently removed because of the complexity and breakage it introduced. And it didn’t work all the time either I discovered :-)
And now, as MothersClick is growing quite fast, we’re hitting this duplicate issue a couple times, which is greatly exacerbated by our integration with groups and email notifications–a duplicate post is now a duplicate email, eek!
So here’s how I solved it for our site. Create a new module for your site, and use hook_nodeapi and hook_comment to catch duplicates before they are saved into the database.
Here’s the code for hook_nodeapi:
And the code for hook_comment:
While this isn’t a 100% guarantee to stop duplicate content, it is now stopping all duplicate content we have seen–and, what makes a better usability test case than your mom? :-)