From: Tim Otten Date: Mon, 2 Jul 2018 22:58:45 +0000 (-0700) Subject: (dev/core#217) Campaign Selector - Change direct SQL call to `prevnext->fillWithSql... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9df3fff5bd80b996d8fc4f61ed526bda64dba6e1;p=civicrm-core.git (dev/core#217) Campaign Selector - Change direct SQL call to `prevnext->fillWithSql(...)` --- diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php index 6f7d3fccab..08b233be67 100644 --- a/CRM/Campaign/Selector/Search.php +++ b/CRM/Campaign/Selector/Search.php @@ -281,18 +281,19 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM $this->_campaignFromClause ); list($select, $from) = explode(' FROM ', $sql); - $insertSQL = " -INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data ) -SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name + $selectSQL = " + SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name FROM {$from} "; - $errorScope = CRM_Core_TemporaryErrorScope::ignoreException(); - $result = CRM_Core_DAO::executeQuery($insertSQL); - unset($errorScope); - if (is_a($result, 'DB_Error')) { + try { + Civi::service('prevnext')->fillWithSql($cacheKey, $selectSQL); + } + catch (CRM_Core_Exception $e) { + // Heavy handed, no? Seems like this merits an explanation. return; } + // also record an entry in the cache key table, so we can delete it periodically CRM_Core_BAO_Cache::setItem($cacheKey, 'CiviCRM Search PrevNextCache', $cacheKey); }