(dev/core#217) PrevNext - Allow swapping `getPositions()` for purposes of contact...
authorTim Otten <totten@civicrm.org>
Mon, 2 Jul 2018 20:32:55 +0000 (13:32 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 25 Jul 2018 01:15:45 +0000 (18:15 -0700)
commitd379a6d907c532c6fbc92ee09ef462d2dc1ce2b2
tree9d1611eb0cc427677f5a8fd9b422cfe0e371d34d
parent0dbe04b1ee4683224f68c2a7e26e989e4b85e99a
(dev/core#217) PrevNext - Allow swapping `getPositions()` for purposes of contact-search

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

```
CRM/Contact/Form/Merge.php:      $pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $this->_cid, $this->_oid, $this->_mergeId, $join, $where, $flip);
CRM/Contact/Form/Merge.php:      $pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, NULL, NULL, $this->_mergeId, $join, $where);
CRM/Contact/Page/View.php:       $pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search $qfKey", $this->_contactId, $this->_contactId);
```

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')->getPositions()`
* Dedupe-merge continues using `CRM_Core_BAO_PrevNextCache::getPositions()`

Note that the `Interface::getPositions()` 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/Page/View.php
CRM/Core/PrevNextCache/Interface.php
CRM/Core/PrevNextCache/Sql.php