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);
$sql = str_replace($replaceSQL, $insertSQL, $sql);
-
CRM_Core_Error::ignoreException();
$result = CRM_Core_DAO::executeQuery($sql);
CRM_Core_Error::setCallback();