Manual sync trying to find civicrm_* tables in wrong database when CiviCRM installed in separate db

Created on 29 April 2022, over 2 years ago
Updated 23 November 2023, about 1 year ago

Problem/Motivation

When pressing manual sync at /admin/config/civicrm/civicrm-group-roles/manual-sync, get this:

Base table or view not found: 1146 Table 'drupal9.civicrm_uf_match' doesn't exist: SELECT "uf"."contact_id" AS "contact_id" FROM "civicrm_uf_match" "uf"; Array () in Drupal\civicrm_group_roles\CivicrmGroupRoles->getSyncContactIds() (line 150 of modules/contrib/civicrm_group_roles-civicrm_group_roles/src/CivicrmGroupRoles.php).

Steps to reproduce

Install CiviCRM in separate database. Press Manually Sync at /admin/config/civicrm/civicrm-group-roles/manual-sync.

Proposed resolution

getSyncContactIds() uses the main database connection:

$select = $this->getDatabase()
      ->select('civicrm_uf_match', 'uf')
      ->fields('uf', ['contact_id']);

Perhaps instead this could be done with API4 (not sure if API3 can do it).

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇦Canada nubeli

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Fixed over 1 year ago
  • 🇮🇳India jitendrapurohit

    Thanks @markusa for the patch. Have tested it successfully and merged the changes (except `civicrm_group_roles.services.yml` file changes since it was already present in the updated version).

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed about 1 year ago
  • 🇬🇧United Kingdom chumkui

    I spent about an hour on this today trying to get it to work before going through the debugger and seeing that it was using the drupal database. Might be worth mentioning that in the readme somewhere that if you have a separate database to ensure that the $databases is set up! Thanks anyway for a great module :-)

Production build 0.71.5 2024