Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.2.8, 2.2.9
-
Fix Version/s: 3.0
-
Component/s: Core CiviCRM
-
Labels:None
Description
SQL to export OpenIDs fails if the requested
location type is anything other than "Primary", producing this error message:
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -2
[message] => DB Error: syntax error
[mode] => 16
[debug_info] => SELECT DISTINCT(contact_a.id) as contact_id, `Home-location_type`.id as `Home-location_type_id`, `Home-location_type`.name as `Home-location_type`, `Home-openid`.id as `Home-openid_id`, `Home-openid`.openid as `Home-openid` FROM civicrm_contact contact_a
LEFT JOIN civicrm_location_type `Home-location_type` ON ( ) WHERE contact_a.id IN ( 87,34,5,57,20,78,64,102 ) GROUP BY contact_a.id [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE contact_a.id IN ( 87,34,5,57,20,78,64,102 ) GROUP BY contact_a.id' at line 2]
[type] => DB_Error
[user_info] => SELECT DISTINCT(contact_a.id) as contact_id, `Home-location_type`.id as `Home-location_type_id`, `Home-location_type`.name as `Home-location_type`, `Home-openid`.id as `Home-openid_id`, `Home-openid`.openid as `Home-openid` FROM civicrm_contact contact_a
LEFT JOIN civicrm_location_type `Home-location_type` ON ( ) WHERE contact_a.id IN ( 87,34,5,57,20,78,64,102 ) GROUP BY contact_a.id [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE contact_a.id IN ( 87,34,5,57,20,78,64,102 ) GROUP BY contact_a.id' at line 2]
[to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT DISTINCT(contact_a.id) as contact_id, `Home-location_type`.id as `Home-location_type_id`, `Home-location_type`.name as `Home-location_type`, `Home-openid`.id as `Home-openid_id`, `Home-openid`.openid as `Home-openid` FROM civicrm_contact contact_a
LEFT JOIN civicrm_location_type `Home-location_type` ON ( ) WHERE contact_a.id IN ( 87,34,5,57,20,78,64,102 ) GROUP BY contact_a.id [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE contact_a.id IN ( 87,34,5,57,20,78,64,102 ) GROUP BY contact_a.id' at line 2]"]
)
Steps to reproduce:
1) Search for contacts
2) Select some contacts to Export
3) choose "Export Contacts"
4) choose "Select Fields for Export"
5) in "Fields to Include in Export File", choose "Individual", "Openid", "Home"
6) click "Export >>"
7) observe error
The bug is caused by a missing case for OpenID with locations in CRM/Contact/BAO/Query.ph
Here's a patch.