1

Under the groups tab in a contact summary if we click to view the smart groups the contact is in we get:

Network Error Unable to reach the server. Please refresh this page in your browser and try again.

We have checked the setting for URLs & Directories & cleared the cache. If we do a search for contacts in the a smart group all is fine. Below is the error & backtrace from the log.

Install is WordPress 5.4 and CiviCRM 5.23.4.

 [debug] $backTrace = #0 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(192): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
#2 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB.php(998): PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2), "SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#3 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-2, 16, (Array:2), "SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#4 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), "SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...", "DB_Error", TRUE)
#5 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7))
#6 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(935): DB_common->raiseError(-2, NULL, NULL, "SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...", "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
#7 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(405): DB_mysqli->mysqliRaiseError()
#8 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1231): DB_mysqli->simpleQuery("SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#9 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2691): DB_common->query("SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#10 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#11 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(421): DB_DataObject->query("SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#12 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1497): CRM_Core_DAO->query("SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...", TRUE)
#13 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php(569): CRM_Core_DAO::singleValueQuery("SELECT COUNT(*)  FROM civicrm_contact contact_a   \nLEFT JOIN  ON .entity_id ...")
#14 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(3191): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
#15 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(3092): CRM_Contact_BAO_Query->addGroupContactCache((Array:1), "civicrm_group_contact_cache_5e8dc68a3c7d6", "contact_a", "IN")
#16 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(1819): CRM_Contact_BAO_Query->group((Array:5))
#17 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(2057): CRM_Contact_BAO_Query->whereClauseSingle((Array:5), FALSE)
#18 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(581): CRM_Contact_BAO_Query->whereClause(FALSE)
#19 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(528): CRM_Contact_BAO_Query->initialize(NULL)
#20 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(4614): CRM_Contact_BAO_Query->__construct((Array:1), (Array:1), (Array:24), TRUE, FALSE, 1, TRUE, TRUE, FALSE, NULL, "AND", NULL, "1")
#21 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php(210): CRM_Contact_BAO_Query::apiQuery((Array:1), (Array:1), NULL, NULL, 0, 0, FALSE)
#22 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php(192): CRM_Contact_BAO_GroupContactCache::add((Array:21))
#23 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php(688): CRM_Contact_BAO_GroupContactCache::loadAll()
#24 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/View/ContactSmartGroup.php(41): CRM_Contact_BAO_GroupContactCache::contactGroup("9445")
#25 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/View/ContactSmartGroup.php(89): CRM_Contact_Page_View_ContactSmartGroup->browse()
#26 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(268): CRM_Contact_Page_View_ContactSmartGroup->run((Array:4), NULL)
#27 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:14))
#28 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:4))
#29 /home/<<account>>/public_html/wp-content/plugins/civicrm/civicrm.php(1449): CRM_Core_Invoke::invoke((Array:4))
#30 /home/<<account>>/public_html/wp-includes/class-wp-hook.php(287): CiviCRM_For_WordPress->invoke("")
#31 /home/<<account>>/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters("", (Array:1))
#32 /home/<<account>>/public_html/wp-includes/plugin.php(478): WP_Hook->do_action((Array:1))
#33 /home/<<account>>/public_html/wp-admin/admin.php(254): do_action("toplevel_page_CiviCRM")
#34 {main}


 [error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => SELECT COUNT(*)  FROM civicrm_contact contact_a   
LEFT JOIN  ON .entity_id = .id  WHERE (contact_a.is_deleted = 0)   AND contact_a.id NOT IN (
                          SELECT contact_id FROM civicrm_group_contact
                          WHERE civicrm_group_contact.status = 'Removed'
                          AND   civicrm_group_contact.group_id = 17 )  [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 'ON .entity_id = .id  WHERE (contact_a.is_deleted = 0)   AND contact_a.id NOT IN ' at line 2]
    [type] => DB_Error
    [user_info] => SELECT COUNT(*)  FROM civicrm_contact contact_a   
LEFT JOIN  ON .entity_id = .id  WHERE (contact_a.is_deleted = 0)   AND contact_a.id NOT IN (
                          SELECT contact_id FROM civicrm_group_contact
                          WHERE civicrm_group_contact.status = 'Removed'
                          AND   civicrm_group_contact.group_id = 17 )  [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 'ON .entity_id = .id  WHERE (contact_a.is_deleted = 0)   AND contact_a.id NOT IN ' at line 2]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT COUNT(*)  FROM civicrm_contact contact_a   
LEFT JOIN  ON .entity_id = .id  WHERE (contact_a.is_deleted = 0)   AND contact_a.id NOT IN (
                          SELECT contact_id FROM civicrm_group_contact
                          WHERE civicrm_group_contact.status = 'Removed'
                          AND   civicrm_group_contact.group_id = 17 )  [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 'ON .entity_id = .id  WHERE (contact_a.is_deleted = 0)   AND contact_a.id NOT IN ' at line 2]"]
)

Thanks in advance for any insight.

  • The LEFT JOIN ON .entity_id part is a clue. It seems like maybe you have a smart group that references a deleted custom field group or something like that? I would try editing and resaving the smart group (group id 17). – Demerit Apr 8 at 18:46
2

Looking at the sql and backtrace, it looks like it is trying to rebuild the smart group id 17. Try resaving the group id 17 search criteria.

| improve this answer | |
  • Yep I was thinking same thing. – Demerit Apr 8 at 18:48
  • That was the issue. The criteria on smart group id 17 was referencing a disabled custom field. The group was not in use so I disabled it and all is good now. Thanks – KilakwaBT Apr 8 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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