- Go to advanced search
- search by name ('adam' gives plenty of results in the example data)
- try to sort by country while tailing Civi log
When no address field is part of the search parameters and you try to sort the results by country, this shows up in the log:
$Fatal Error Details = Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => exceptionHandler ) [code] => -19 [message] => DB Error: no such field [mode] => 16 [debug_info] => INSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data) SELECT DISTINCT 'civicrm search CRMContactControllerSearch17zo40ot8i74g4o4gko0sk0wc0osw040owossgk008wc484s4w_9435', contact_a.id, contact_a.sort_name FROM civicrm_contact contact_a LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1) LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id WHERE ( ( ( ( contact_a.sort_name LIKE '%adam%' ) OR ( civicrm_email.email LIKE '%adam%' ) ) ) ) AND ( 1 ) AND (contact_a.is_deleted = 0) ORDER BY `country` asc, `contact_a`.`id` LIMIT 0, 500 [nativecode=1054 ** Unknown column 'civicrm_address.country_id' in 'on clause'] [type] => DB_Error ... ) Dec 02 01:56:07 [debug] $backTrace = #0 /srv/civi-sites/wmff/drupal/sites/all/modules/civicrm/CRM/Core/Error.php(954): CRM_Core_Error::backtrace("backTrace", TRUE) #1 /srv/civi-sites/wmff/drupal/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(944): CRM_Core_Error::exceptionHandler(Object(DB_Error)) ... #14 /srv/civi-sites/wmff/drupal/sites/all/modules/civicrm/CRM/Core/PrevNextCache/Sql.php(43): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_prevnext_cache (cachekey, entity_id1, data)\nSELECT DIS...", (Array:0), FALSE) #15 /srv/civi-sites/wmff/drupal/sites/all/modules/civicrm/CRM/Contact/Selector.php(1057): CRM_Core_PrevNextCache_Sql->fillWithSql("civicrm search CRMContactControllerSearch17zo40ot8i74g4o4gko0sk0wc0osw040owos...", "SELECT DISTINCT 'civicrm search CRMContactControllerSearch17zo40ot8i74g4o4gko...")
Note that the sort appears to change in the UI anyway, but that may just be sorting the current page in JS.
Looks like it's missing a join on the address table. There is a similar-sounding issue filed against upstream ( https://lab.civicrm.org/dev/core/-/issues/3836 ) but the proposed fix for that one doesn't work here.