convert to central function
[civicrm-core.git] / CRM / Core / BAO / PrevNextCache.php
index ca53363abf82427667e353bb0dcf762ef76d8450..d47c44ff91df7c56ee85de0ef42750e0b8f6ce5a 100644 (file)
@@ -121,32 +121,6 @@ WHERE  cachekey     = %3 AND
     CRM_Core_DAO::executeQuery($sql, $params);
   }
 
-  /**
-   * Delete pair from the previous next cache table to remove it from further merge consideration.
-   *
-   * The pair may have been flipped, so make sure we delete using both orders
-   *
-   * @param int $id1
-   * @param int $id2
-   * @param string $cacheKey
-   */
-  public static function deletePair($id1, $id2, $cacheKey = NULL) {
-    $sql = "DELETE FROM civicrm_prevnext_cache WHERE  entity_table = 'civicrm_contact'";
-
-    $pair = "(entity_id1 = %2 AND entity_id2 = %3) OR (entity_id1 = %3 AND entity_id2 = %2)";
-    $sql .= " AND ( {$pair} )";
-    $params[2] = [$id1, 'Integer'];
-    $params[3] = [$id2, 'Integer'];
-
-    if (isset($cacheKey)) {
-      $sql .= " AND cachekey LIKE %4";
-      // used % to address any row with conflict-cacheKey e.g "merge Individual_8_0_conflicts"
-      $params[4] = ["{$cacheKey}%", 'String'];
-    }
-
-    CRM_Core_DAO::executeQuery($sql, $params);
-  }
-
   /**
    * Mark contacts as being in conflict.
    *
@@ -326,6 +300,7 @@ FROM   civicrm_prevnext_cache pn
    * @return array
    */
   public static function convertSetItemValues($sqlValues) {
+    CRM_Core_Error::deprecatedFunctionWarning('Deprecated function');
     $closingBrace = strpos($sqlValues, ')') - strlen($sqlValues);
     $valueArray = array_map('trim', explode(', ', substr($sqlValues, strpos($sqlValues, '(') + 1, $closingBrace - 1)));
     foreach ($valueArray as $key => &$value) {
@@ -350,7 +325,7 @@ FROM   civicrm_prevnext_cache pn
     CRM_Core_Error::deprecatedFunctionWarning('Deprecated function');
     // If entity table is an array we are passing in an older format where this function only had 1 param $values. We put a deprecation warning.
     if (!empty($entity_table) && is_array($entity_table)) {
-      Civi::log()->warning('Deprecated code path. Values should not be set this is going away in the future in favour of specific function params for each column.', array('civi.tag' => 'deprecated'));
+      CRM_Core_Error::deprecatedWarning('Deprecated code path. Values should not be set this is going away in the future in favour of specific function params for each column.');
       foreach ($values as $value) {
         $valueArray = self::convertSetItemValues($value);
         self::setItem($valueArray[0], $valueArray[1], $valueArray[2], $valueArray[3], $valueArray[4]);
@@ -462,7 +437,13 @@ WHERE (pn.cachekey $op %1 OR pn.cachekey $op %2)
     }
   }
 
+  /**
+   * Old function to clean up he cache.
+   *
+   * @deprecated.
+   */
   public static function cleanupCache() {
+    CRM_Core_Error::deprecatedFunctionWarning('Deprecated function');
     Civi::service('prevnext')->cleanup();
   }
 
@@ -476,6 +457,7 @@ WHERE (pn.cachekey $op %1 OR pn.cachekey $op %2)
    * @see CRM_Core_PrevNextCache_Sql::getSelection()
    */
   public static function getSelection($cacheKey, $action = 'get') {
+    CRM_Core_Error::deprecatedFunctionWarning('Deprecated function');
     return Civi::service('prevnext')->getSelection($cacheKey, $action);
   }
 
@@ -533,6 +515,8 @@ WHERE (pn.cachekey $op %1 OR pn.cachekey $op %2)
    * @param array $fieldDef
    * @param int $counter
    *   The globally-unique ID of the test object.
+   *
+   * @throws \CRM_Core_Exception
    */
   protected function assignTestValue($fieldName, &$fieldDef, $counter) {
     if ($fieldName === 'cachekey') {