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 »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Groups Problem
Pages: [1]

Author Topic: Groups Problem  (Read 398 times)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Groups Problem
January 28, 2013, 06:06:47 am
The "View Contacts" link for group id 92 for a CiviCRM 4.2.6 site is:

Code: [Select]
INSERT IGNORE INTO civicrm_group_contact_cache (group_id,contact_id) (
SELECT 92 as group_id, contact_id as id
FROM   civicrm_group_contact
WHERE  civicrm_group_contact.status = 'Added'
  AND  civicrm_group_contact.group_id = 92 );

but it fails with

Quote
Cannot add or update a child row: a foreign key constraint fails (`civicrm_group_contact_cache`, CONSTRAINT `FK_civicrm_group_contact_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]

What is the reason it fails? Because the SELECT brings up a set of non-existent contacts. I made this SQL to test:

Code: [Select]
SELECT 92 as group_id, contact_id as id
FROM   civicrm_group_contact
LEFT JOIN   civicrm_contact cc on cc.id = civicrm_group_contact.contact_id
WHERE  civicrm_group_contact.status = 'Added'
  AND  civicrm_group_contact.group_id = 92
  and cc.id is null;

and it finds 35 rows in civicrm_group_contact where the contact_id doesn't exist in civicrm_contact.

I can remove those 35 rows but I am wondering how they got there....
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Groups Problem

This forum was archived on 2017-11-26.