Empty smart groups in CiviReport

We recently came across an odd problem with CiviReport. Every once in a while (hint, hint) CiviReport would display 0 results even though the smart group it was referencing did in fact have contacts. After spending some time going through the code with Xdebug and our favorite debugger we were not able to track down why the civicrm_group_contact_cache table would "randomly" empty itself.

Lobo and Deepak from the CiviCRM core team gave it their best, with Deepak even logging into our sandbox to help troubleshoot. The end result was, "well, it should just work if you update the smart group." Our savvy client already knew that updating the smart group fixes it but also knew that eventually the civicrm_group_contact_cache would be empty again.

We thought it might have something to do with cron and possibly some other module emptying the table, not CiviCRM. This particular site is running the Elysia Cron module so we rebuilt the cache table and starting manually running each of the jobs watching for the cache table to empty. The culprit turned out to be the CD Sunlight module. The client had 6.x-2.0 installed which is not compatible with CiviCRM 3.2.x/3.3.x. Using our debugger again, we isolated the problem to line 1618,

$contact = civicrm_contact_add($contact);

which tries to update a contact with their congressional district information and in the process clearing the civicrm_group_contact_cache table.

Updating to 6.x-3.0 solved the problem and provides compatibility with CiviCRM 3.3.x.

We also took the extra step to figure out why exactly CiviReport wasn't checking and populating the cache table. We filed a report on the CiviCRM issue tracker with a proposed patch.

Update: We've identified another bug related to caching behavior. You can read the details, but the moral of the story is: when comparing time/date stamps, make sure they come from the same source. Don't mix a database now() and PHP date() call. If you do, make sure you set a default timezone otherwise Drupal will use it's own timezone.

Comments

  • Showing 1-0 of 0

Post new comment

Image CAPTCHA
Enter the characters shown in the image.