0

I'm trying to figure out how to debug the following behavior and would appreciate some ideas on how to track down the source of the problem.

I run a website were some users have privileges to create and edit nodes and taxonomy terms.

Upon creating content or taxonomy terms, users report that, on occasion, content is created 3 times, for both entity types.

What steps can I take to find the culprit for this behavior knowing that...?

  1. I have made sure users only click the submit button once, but that hasn't made any difference.
  2. Both Drupal and PHP error logs are clean. I can see 3 logged messages confirming content has been triplicated but nothing else.
  3. It only happens in live environment. I haven't been able to reproduce it in development environment
  4. It happens randomly. Users have reported this only happens ocasionally.
  5. When this happens, any rules that react to the condition 'After saving node ...' or 'After updating node...' are also fired 3 times
1

Treat it like any bug:

  1. Find a way to reliably reproduce the problem (this is essential to debugging any code issue for obvious reasons; the question "how do I debug this problem I can't reproduce?" doesn't have an answer, let alone a Drupal-specific one). You may need to set up a clone of your production environment as the issue might not be related to Drupal (e.g. you could have a rogue process duplicating MySQL records that Drupal doesn't get involved with)
  2. Fire up XDebug or your debugger of choice.
  3. Step through every single line of the code that gets involved in the problem you're seeing, keeping an eye on what parameters are being passed to methods, and if they contain the expected data. Basically run through an entire bootstrap for the page(s) you're having problems with, starting at index.php, narrowing down your target search area as you go.
  4. Fix when you've identified the problem (you're not done yet though...)
  5. To help for next time, write a test that fails before you implement your fix, and passes afterwards. Make it part of your deployment workflow to run this test after every change you make. Consider adding tests for other major pieces of functionality as you decide which are the most important, to help avoid this sort of situation in future.
2
  • I was really hoping to avoid having to clone the whole production site, since it is 14GB+ in size and my hosting resources are limited. I suppose I shall give it a try as my last resource. Thanks! – bmunslow Nov 26 '15 at 14:16
  • If a sizeable chunk of that is the sites/all/files folder you can almost definitely get away with leaving that behind, unless of course something in there is causing the problem! You can also exclude cache and watchdog tables to save a bit of space – Clive Nov 26 '15 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.