(dev/core#217) PrevNext - Allow swapping `getCount()` for purposes of contact-search
authorTim Otten <totten@civicrm.org>
Mon, 2 Jul 2018 23:57:51 +0000 (16:57 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 25 Jul 2018 01:15:45 +0000 (18:15 -0700)
commitc93f3d19924f4467d76f8d62bd7db4f495cde76b
tree6fd32c9942e08f75378739cea2cb2865f0fef209
parent744b4e344aa23fbb4655797b057244109dfb2c61
(dev/core#217) PrevNext - Allow swapping `getCount()` for purposes of contact-search

The `getCount()` function is used by both contact-search and dedupe-merge use-cases.

* Contact-search
    * `CRM/Contact/Selector.php:            $countRow = CRM_Core_BAO_PrevNextCache::getCount($cacheKey, NULL, "entity_table = 'civicrm_contact'");`
* Dedupe-merge
    * `CRM/Contact/Page/AJAX.php:           $iTotal   = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, $join, $whereClause, '=', $queryParams);`
    * `CRM/Contact/Page/DedupeMerge.php:    $total    = CRM_Core_BAO_PrevNextCache::getCount($cacheKeyString, NULL, ($onlyProcessSelected ? "pn.is_selected = 1" : NULL));`

Our aim in developing `CRM_Core_PrevNextCache_Interface` is to allow contact-search to swap a MySQL
backend with a Redis backend -- and dedupe-merge should continue as-is (whether or not Redis is
available).  This basically means:

* Contact-search switches to using `Civi::service('prevnext')->getCount()`
* Dedupe-merge continues using `CRM_Core_BAO_PrevNextCache::getCount()`

Note that the `Interface::getCount()` is simpler than the BAO's variant. This is good because:

* Contact-search doesn't need as many parameters.
* Dedupe-merge still needs all the parameters.
* Adding all parameters would make it hard to implement on other backends. (This is esp true of SQL-style options `$join` and `$where`.)
CRM/Contact/Selector.php
CRM/Core/PrevNextCache/Interface.php
CRM/Core/PrevNextCache/Sql.php