diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 10c3189d3a79..c436d83a1bdc 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -38,6 +38,8 @@ */ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Selector_API { + const CACHE_SIZE = 500; + /** * This defines two actions- View and Edit. * @@ -901,10 +903,10 @@ public function buildPrevNextCache($sort) { // $sortByCharacter triggers a refresh in the prevNext cache if ($sortByCharacter && $sortByCharacter != 'all') { $cacheKey .= "_alphabet"; - $this->fillupPrevNextCache($sort, $cacheKey, 0, max(500, $pageSize)); + $this->fillupPrevNextCache($sort, $cacheKey, 0, max(self::CACHE_SIZE, $pageSize)); } elseif (($firstRecord + $pageSize) >= $countRow) { - $this->fillupPrevNextCache($sort, $cacheKey, $countRow, max(500, $pageSize) + $firstRecord - $countRow); + $this->fillupPrevNextCache($sort, $cacheKey, $countRow, max(self::CACHE_SIZE, $pageSize) + $firstRecord - $countRow); } return $cacheKey; } @@ -1020,7 +1022,7 @@ public function removeActions(&$rows) { * @param int $start * @param int $end */ - public function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = 500) { + public function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = self::CACHE_SIZE) { $coreSearch = TRUE; // For custom searches, use the contactIDs method if (is_a($this, 'CRM_Contact_Selector_Custom')) { @@ -1090,7 +1092,7 @@ public function rebuildPreNextCache($start, $end, $sort, $cacheKey) { $dao = CRM_Core_DAO::executeQuery($sql); - // build insert query, note that currently we build cache for 500 contact records at a time, hence below approach + // build insert query, note that currently we build cache for 500 (self::CACHE_SIZE) contact records at a time, hence below approach $insertValues = array(); while ($dao->fetch()) { $insertValues[] = "('civicrm_contact', {$dao->contact_id}, {$dao->contact_id}, '{$cacheKey}', '" . CRM_Core_DAO::escapeString($dao->sort_name) . "')";