Drupal issueshttps://lab.civicrm.org/dev/drupal/-/issues2023-11-09T23:29:43Zhttps://lab.civicrm.org/dev/drupal/-/issues/20Manual synchronization of CiviCRM memberships and Drupal roles gives error2023-11-09T23:29:43Zcarbar1103Manual synchronization of CiviCRM memberships and Drupal roles gives errorHello.
I am just starting to get memberships and roles sorted out in my CiviCRM. When I go to Home » Administration » Configuration » CiviCRM » CiviMember Roles Sync » Manually Synchronize and click the button, I get a popup saying "Th...Hello.
I am just starting to get memberships and roles sorted out in my CiviCRM. When I go to Home » Administration » Configuration » CiviCRM » CiviMember Roles Sync » Manually Synchronize and click the button, I get a popup saying "There was an error. CiviMember Memberships and Drupal Roles could not be synchronized." The Drupal log just says "unknown error".
On investigation, the problem appears in drupal/modules/civicrm_member_roles/civicrm_member_roles.module, line 530, in the method _civicrm_member_roles_sync():
```
$contacts = CRM_Core_DAO::executeQuery($sql, $params);
if ($contacts->N == 0) {
watchdog('civicrm_member_roles',
$errorMsg,
$errorParams,
WATCHDOG_ERROR
);
return FALSE;
}
```
It is running the following sql:
```
SELECT DISTINCT uf.contact_id, m.end_date FROM civicrm_uf_match uf
LEFT JOIN civicrm_membership m ON uf.contact_id = m.contact_id
WHERE m.id IS NOT NULL AND m.membership_type_id IN (1)
ORDER BY m.end_date DESC
```
which is returning zero rows. This is probably because I haven't got the necessary roles/contacts/etc set up, but it is a bit of an odd error.
Regards,
Carl