CRM-13996, fixes sorting for search views
authorkurund <kurund@civicrm.org>
Wed, 15 Jan 2014 23:10:07 +0000 (15:10 -0800)
committerkurund <kurund@civicrm.org>
Wed, 15 Jan 2014 23:10:07 +0000 (15:10 -0800)
----------------------------------------
* 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

CRM/Contact/Selector.php

index 4d465137a19de9742e491bd740b3f01165516f85..0e13abdea1828cc98ef378312a4cd827373c0a53 100644 (file)
@@ -509,6 +509,11 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
     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);