X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FGroupContactCache.php;h=a88d317325675d0aa44f7623b0036b4d1ed86331;hb=1215d7b11e1be7d3e69b2c374c4a0398684a277d;hp=9e13d05bd805d8ea577e1d9c1497513e3f7a5706;hpb=06b69b1899b6304f7832f6d4d2f5af4a0acfde8c;p=civicrm-core.git diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index 9e13d05bd8..a88d317325 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -40,7 +40,9 @@ class CRM_Contact_BAO_GroupContactCache extends CRM_Contact_DAO_GroupContactCach * Check to see if we have cache entries for this group * if not, regenerate, else return * - * @param int $groupID groupID of group that we are checking against + * @param $groupIDs + * + * @internal param int $groupID groupID of group that we are checking against * * @return boolean true if we did not regenerate, false if we did */ @@ -188,6 +190,18 @@ AND g.refresh_date IS NULL } } + /** + * FIXME: This function should not be needed, because the cache table should not be getting truncated + */ + static function fillIfEmpty() { + if (!CRM_Core_DAO::singleValueQuery("SELECT COUNT(id) FROM civicrm_group_contact_cache")) { + self::loadAll(); + } + } + + /** + * @param $groupID + */ static function add($groupID) { // first delete the current cache self::remove($groupID); @@ -203,6 +217,10 @@ AND g.refresh_date IS NULL } } + /** + * @param $groupID + * @param $values + */ static function store(&$groupID, &$values) { $processed = FALSE; @@ -433,6 +451,7 @@ WHERE id = %1 $customClass = CRM_Contact_BAO_SearchCustom::customClass($ssParams['customSearchID'], $savedSearchID); $searchSQL = $customClass->contactIDs(); + $searchSQL = str_replace('ORDER BY contact_a.id ASC', '', $searchSQL); $idName = 'contact_id'; } else { @@ -531,6 +550,9 @@ AND civicrm_group_contact.group_id = $groupID "; $lock->release(); } + /** + * @return int + */ static function smartGroupCacheTimeout() { $config = CRM_Core_Config::singleton(); @@ -614,7 +636,7 @@ ORDER BY gc.contact_id, g.children $contactGroup[$prevContactID]['groupTitle'] = implode(', ', $contactGroup[$prevContactID]['groupTitle']); } - if (is_numeric($contactID)) { + if ((!empty($contactGroup[$contactID]) && is_numeric($contactID))) { return $contactGroup[$contactID]; } else {