CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Smart group not right after test upgrade from 4.0.7 to 4.2.6
Pages: [1]

Author Topic: Smart group not right after test upgrade from 4.0.7 to 4.2.6  (Read 1132 times)

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Smart group not right after test upgrade from 4.0.7 to 4.2.6
November 23, 2012, 06:05:55 am
I've done a trial upgrade from 4.0.7 to 4.2.6.  I've temporarily removed all customisations.

I have a smart group (or two) which aren't working as I expect.  I find the group in Manage Groups then click on Contacts.  It lists 12 contacts.  If I click on Edit Smart Group Search Criteria I immediately see the expected result of 551 contacts.  If I do a Update Smart Group etc the count remains at 12.

If I re-create the group from scratch, the same problem arises.

For a contact in the 12 the group is listed as "Added (by Admin)".
For one of the non-listed contacts that should be in the group, this wasn't present.

Any ideas?

Thanks in advance

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
November 23, 2012, 08:50:44 am

can you try and reproduce this on our demo server if possible

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
November 23, 2012, 12:15:26 pm
I set up a similar search in the demo site and it works OK.  Chris

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
November 26, 2012, 05:45:12 am
Where do you suggest I start looking in the code to see what's going wrong?  Ta Chris

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
November 26, 2012, 06:55:39 am

can you create another smart group with the same parameters new in 4.2.6 and see if that works

if i had to guess, something changed in the search protocol and it is not backward compatible and hence the errors. but this is just a random guess

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
November 26, 2012, 07:05:59 am
I've already tried that andthe same thing happens.  Ta Chris

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
December 12, 2012, 08:34:03 am
I've found that civicrm_group_contact_cache is not being updated correctly in CRM\Contact\BAO\GroupContactCache.php around line 344-346.  (This code has changed from v4.0.7.)

Code: [Select]
      $insertSql = "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) ($selectSql);";
      $processed = TRUE; // FIXME
      $result = CRM_Core_DAO::executeQuery($insertSql);

The $selectSql is OK (see below) ie it returns the desired number of records (540).  The INSERT only inserts 12 because of a UI_contact_group unique index constraint (contact_id, group_id), with IGNORE meaning that such problems aren't reported.  There aren't such duplicates when I run the SELECT by itself.

This is weird.  If I limit the select to one record I get
group_id    contact_id
20    26841
If I then put the INSERT (no IGNORE) on the front, then I get
Duplicate entry '27037-20' for key 'UI_contact_group'
ie the contact_id is different.

This is the normal select clause:
Code: [Select]
SELECT 20 as group_id, contact_a.id as contact_id FROM civicrm_contact contact_a
LEFT JOIN civicrm_membership ON civicrm_membership.contact_id = contact_a.id LEFT JOIN
civicrm_contribution_recur ccr ON ( civicrm_membership.contribution_recur_id = ccr.id )
WHERE ( contact_a.contact_type IN ('Organization') AND civicrm_membership.membership_type_id = 7 AND
civicrm_membership.status_id IN ('1','2','3') AND civicrm_membership.is_test = 0 ) AND (contact_a.is_deleted = 0)
AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact WHERE civicrm_group_contact.status = 'Removed'
AND civicrm_group_contact.group_id = 20 )

I'm running 5.1.49-1ubuntu8.1

Any help most appreciated as I'm stumped at the moment.  Thanks Chris

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
December 12, 2012, 09:22:10 am
Here's a redefinition of the problem I'm seeing:

The SELECT seems to return 540 rows when run by itself but only 12 when run as part of the INSERT

ie ignore most of my previous post.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
December 12, 2012, 09:28:03 am

chris:

1. can u share the DB

2. ping me on irc and we can help debug / trace the problem

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
December 12, 2012, 09:52:11 am
Thanks

I'd best not make the db available sorry.

Can we do a Skype screenshare (I'm chriscant) or teamviewer.com share? eg to let you use phpMyAdmin.
Either later tonight - it's almost 6pm UK time and I should be free at 9pm.
Or tomorrow some time.

Thanks very much in advance

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: Smart group not right after test upgrade from 4.0.7 to 4.2.6
December 14, 2012, 07:37:55 am
If I spin through the SELECT it works now.  I changed the preceding definition of $sqlB so that the second column is always called id.

Code: [Select]
    $sqlB = "
SELECT $groupID as group_id, contact_id as id
FROM   civicrm_group_contact
WHERE  civicrm_group_contact.status = 'Added'
  AND  civicrm_group_contact.group_id = $groupID ";

...

      $dao = CRM_Core_DAO::executeQuery($insertSql);
      while ($dao->fetch()) {
        $gid = $dao->group_id;
        $contactid = $dao->id;
        $insertSql = "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) VALUES($gid,$contactid);";
        $result = CRM_Core_DAO::executeQuery($insertSql);
      }
      //$insertSql = "INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) ($selectSql);";
      $processed = TRUE; // FIXME
      //$result = CRM_Core_DAO::executeQuery($insertSql);

To me it feels like a MySql bug that I need to do this but in a quick look I could not see such issues reported.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Smart group not right after test upgrade from 4.0.7 to 4.2.6

This forum was archived on 2017-11-26.