CRM-14939 - ensure proper pagination of search results past page 10.
authorJamie McClelland <jm@mayfirst.org>
Mon, 7 Jul 2014 15:00:30 +0000 (11:00 -0400)
committerJamie McClelland <jm@mayfirst.org>
Mon, 7 Jul 2014 15:00:30 +0000 (11:00 -0400)
----------------------------------------
* CRM-14939: unpredictable behavior with pagination of search results with duplicates
  https://issues.civicrm.org/jira/browse/CRM-14939

CRM/Contact/Selector.php

index ad3f6f119b2216522acfc11037052d98895d2103..d6a8bfc37de19765e2ea3d5710a6f8ea55259a4c 100644 (file)
@@ -807,7 +807,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
       $this->fillupPrevNextCache($sort, $cacheKey);
     }
     elseif ($firstRecord >= $countRow) {
-      $this->fillupPrevNextCache($sort, $cacheKey, $countRow, $firstRecord + 500);
+      $this->fillupPrevNextCache($sort, $cacheKey, $countRow, 500);
     }
     return $cacheKey;
   }
@@ -918,7 +918,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
 
     $insertSQL = "
 INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data )
-SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
+SELECT DISTINCT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
 ";
 
     $sql = str_replace($replaceSQL, $insertSQL, $sql);