----------------------------------------
* CRM-13996: Advanced Search; Sorting of Results displayed in a custom profile fails and Advanced Search must be reset
http://issues.civicrm.org/jira/browse/CRM-13996
if ($rowCount) {
$cacheKey = $this->buildPrevNextCache($sort);
$result = $this->_query->getCachedContacts($cacheKey, $offset, $rowCount, $includeContactIds);
+
+ // CRM-13996: result is empty when selector columns are sorted. hence we need to run the query again
+ if ( $result->N == 0) {
+ $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
+ }
}
else {
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);