Skip to content

Commit

Permalink
Merged in 4.6.20 (pull request civicrm#21)
Browse files Browse the repository at this point in the history
Update to 4.6.20
  • Loading branch information
seamuslee001 committed Aug 11, 2016
2 parents faee6a1 + 0b3ed1f commit 04b7cf1
Show file tree
Hide file tree
Showing 209 changed files with 3,027 additions and 775 deletions.
12 changes: 3 additions & 9 deletions CRM/ACL/BAO/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,14 @@ public static function resetCache() {
// reset any static caching
self::$_cache = NULL;

// reset any db caching
$config = CRM_Core_Config::singleton();
$smartGroupCacheTimeout = CRM_Contact_BAO_GroupContactCache::smartGroupCacheTimeout();

//make sure to give original timezone settings again.
$now = CRM_Utils_Date::getUTCTime();

$query = "
DELETE
FROM civicrm_acl_cache
WHERE modified_date IS NULL
OR (TIMESTAMPDIFF(MINUTE, modified_date, $now) >= $smartGroupCacheTimeout)
OR (modified_date <= %1)
";
CRM_Core_DAO::singleValueQuery($query);
$params = array(1 => array(CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), 'String'));
CRM_Core_DAO::singleValueQuery($query, $params);

// CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction
// CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe
Expand Down
7 changes: 4 additions & 3 deletions CRM/ACL/DAO/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO
/**
* When was this cache entry last modified
*
* @var date
* @var timestamp
*/
public $modified_date;
/**
Expand Down Expand Up @@ -159,9 +159,10 @@ static function &fields()
) ,
'modified_date' => array(
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE,
'title' => ts('Modified Date') ,
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Cache Modified Date') ,
'description' => 'When was this cache entry last modified',
'required' => false,
) ,
);
}
Expand Down
3 changes: 1 addition & 2 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ public static function create(&$params) {
}
}

// reset the group contact cache since smart groups might be affected due to this
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();

if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Case/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public function postProcess($params = NULL) {
if ($this->_activityId) {
// retrieve and include the custom data of old Activity
$oldActivity = civicrm_api3('Activity', 'getsingle', array('id' => $this->_activityId));
$params = array_merge($params, $oldActivity);
$params = array_merge($oldActivity, $params);

// unset custom fields-id from params since we want custom
// fields to be saved for new activity.
Expand Down
16 changes: 7 additions & 9 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,12 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE
$config = CRM_Core_Config::singleton();

// CRM-6942: set preferred language to the current language if it’s unset (and we’re creating a contact).
if (empty($params['contact_id'])) {
// A case could be made for checking isset rather than empty but this is more consistent with previous behaviour.
if (empty($params['preferred_language']) && ($language = CRM_Core_I18n::getContactDefaultLanguage()) != FALSE) {
$params['preferred_language'] = $language;
}
if (empty($params['contact_id']) && empty($params['preferred_language'])) {
$params['preferred_language'] = $config->lcMessages;
}

// CRM-9739: set greeting & addressee if unset and we’re creating a contact.
// CRM-9739: set greeting & addressee if unset and we’re creating a contact.
if (empty($params['contact_id'])) {
foreach (self::$_greetingTypes as $greeting) {
if (empty($params[$greeting . '_id'])) {
if ($defaultGreetingTypeId
Expand Down Expand Up @@ -920,7 +919,7 @@ public static function updateContactCache($contactID, $isTrashed = FALSE) {
CRM_Core_DAO::executeQuery('DELETE FROM civicrm_acl_contact_cache WHERE contact_id = %1', array(1 => array($contactID, 'Integer')));
}
else {
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
}
}

Expand Down Expand Up @@ -1949,8 +1948,7 @@ public static function createProfileContact(
CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $addToGroupID);
}

// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();

if ($editHook) {
CRM_Utils_Hook::post('edit', 'Profile', $contactID, $params);
Expand Down
3 changes: 1 addition & 2 deletions CRM/Contact/BAO/Contact/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,7 @@ public static function clearContactCaches($contactID = NULL) {
CRM_Core_BAO_PrevNextCache::deleteItem();
}

// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contact/BAO/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function isActive($contactType) {
* @return array
* Array of basic contact types information.
*/
public static function &basicTypeInfo($all = FALSE) {
public static function basicTypeInfo($all = FALSE) {
static $_cache = NULL;

if ($_cache === NULL) {
Expand Down Expand Up @@ -153,7 +153,7 @@ public static function basicTypePairs($all = FALSE, $key = 'name') {
* @return array
* Array of sub type information
*/
public static function &subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
public static function subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
static $_cache = NULL;

if ($reset === TRUE) {
Expand Down
8 changes: 7 additions & 1 deletion CRM/Contact/BAO/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function addContactsToGroup(

// reset the group contact cache for all group(s)
// if this group is being used as a smart group
CRM_Contact_BAO_GroupContactCache::remove();
CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();

CRM_Utils_Hook::post('create', 'GroupContact', $groupId, $contactIds);

Expand Down Expand Up @@ -252,6 +252,12 @@ public static function removeContactsFromGroup(

// reset the group contact cache for all group(s)
// if this group is being used as a smart group
// @todo consider what to do here - it feels like we should either
// 1) just invalidate the specific group's cache(& perhaps any parents) & let cron do it's thing or
// possibly clear this specific groups cache, or just call opportunisticCacheFlush() - which would have the
// same effect as the remove call. The reservation about that is that it is no more aggressive for the group that
// we know is altered than for all the others, or perhaps, more the point with it's parents & groups that use it in
// their criteria.
CRM_Contact_BAO_GroupContactCache::remove();

CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds);
Expand Down
Loading

0 comments on commit 04b7cf1

Please sign in to comment.