2

Yesterday I asked a question that I thought expressed the problem I was having, but this morning as I tried to implement a fix, I realized that this CiviCRM site has a more serious problem. There is a fundamental problem with either or both of relationship data and relationship interfaces on a site I manage.

Contact Page symptoms:

  1. for "broken" contacts (which is most of them), the relationships tab appears empty even if "employer" field is filled in on the individual contact summary page
  2. if I attempt to add the employer relationship on the relationships tab of either the individual or the org, I get an on-screen error saying the relationship exists.
  3. if I delete the employer field on the individual contact I can add the relationship on the relationships tab, but it doesn't appear and doesn't work.

I have discovered I can "repair" an organizational contact by creating a new one and merging the old one into it. This seems to read the data and write it properly to the new contact. This has the obvious disadvantages of changing CID and also of being a tedious manual task. This seems to repair the relevant individual contact too, so it seems likely the data problem is in how the relationships are written.

Is there a way to realistically examine the relevant data tables to see if there is a correctable problem? I do not know when the problem started.

There are no visible back end errors in Civi or Apache.

2
  • This is possibly relationship_cache corruption? There should be 2x as many entries in this table as in the relationships table. I'd start with that.
    – Demerit
    Commented Dec 14, 2023 at 0:36
  • Thanks @Demerit So armed with that information, I can confirm a problem there. There are 2159 rows in civicrm_relationship and only 222 rows in civicrm_relationship_cache. Is there a way to rebuild the cache? I tried the "rebuild triggers" function, but as I expected, that didn't seem to have an effect. I'm not afraid of command line mariadb, but I'm far from expert.
    – kapn
    Commented Dec 14, 2023 at 20:09

1 Answer 1

4

Based on comments the relationship_cache table is incomplete. Since you've already rebuilt the triggers (missing triggers may have been the cause of it not getting populated), the cache just needs repopulating. Run this from the command line:

cv ev 'CRM_Contact_BAO_RelationshipCache::rebuild();'
1
  • 2
    Thank you @Demerit Your expertise and kindness saved me many hours.
    – kapn
    Commented Dec 15, 2023 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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