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`.)
'nextPrevError' => 0,
);
if ($qfKey) {
- $pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search $qfKey",
+ $pos = Civi::service('prevnext')->getPositions("civicrm search $qfKey",
$this->_contactId,
$this->_contactId
);
*/
public function getSelection($cacheKey, $action = 'get');
+ /**
+ * Get the previous and next keys.
+ *
+ * @param string $cacheKey
+ * @param int $id1
+ * @param int $id2
+ *
+ * @return array
+ */
+ public function getPositions($cacheKey, $id1, $id2);
+
}
}
}
+ /**
+ * Get the previous and next keys.
+ *
+ * @param string $cacheKey
+ * @param int $id1
+ * @param int $id2
+ *
+ * NOTE: I don't really get why there are two ID columns, but we'll
+ * keep passing them through as a matter of safe-refactoring.
+ *
+ * @return array
+ */
+ public function getPositions($cacheKey, $id1, $id2) {
+ return CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $id1, $id2);
+ }
+
}