Commit 9df3fff5 authored by totten's avatar totten

(#217) Campaign Selector - Change direct SQL call to `prevnext->fillWithSql(...)`

parent 83068a64
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment