$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 (TIMESTAMPDIFF(MINUTE, modified_date, NOW()) >= $smartGroupCacheTimeout)
";
CRM_Core_DAO::singleValueQuery($query);
*/
public static function groupRefreshedClause($groupIDClause = NULL, $includeHiddenGroups = FALSE) {
$smartGroupCacheTimeout = self::smartGroupCacheTimeout();
- $now = CRM_Utils_Date::getUTCTime();
$query = "
SELECT g.id
WHERE ( g.saved_search_id IS NOT NULL OR g.children IS NOT NULL )
AND g.is_active = 1
AND ( g.cache_date IS NULL OR
- ( TIMESTAMPDIFF(MINUTE, g.cache_date, $now) >= $smartGroupCacheTimeout ) OR
- ( $now >= g.refresh_date )
+ ( TIMESTAMPDIFF(MINUTE, g.cache_date, NOW()) >= $smartGroupCacheTimeout ) OR
+ ( NOW() >= g.refresh_date )
)
";
if (!empty($refreshGroupIDs)) {
$refreshGroupIDString = CRM_Core_DAO::escapeString(implode(', ', $refreshGroupIDs));
- $time = CRM_Utils_Date::getUTCTime(self::smartGroupCacheTimeout() * 60);
+ $time = self::getRefreshDateTime();
$query = "
UPDATE civicrm_group g
SET g.refresh_date = $time
if ($processed) {
// also update the group with cache date information
//make sure to give original timezone settings again.
- $now = CRM_Utils_Date::getUTCTime();
+ $now = date('YmdHis');
$refresh = 'null';
}
else {
$params = array();
$smartGroupCacheTimeout = self::smartGroupCacheTimeout();
- $now = CRM_Utils_Date::getUTCTime();
- $refreshTime = CRM_Utils_Date::getUTCTime($smartGroupCacheTimeout * 60);
+ $refreshTime = self::getRefreshDateTime();
if (!isset($groupID)) {
if ($smartGroupCacheTimeout == 0) {
}
}
+ /**
+ * Get the date when the cache should be refreshed from.
+ *
+ * Ie. now + the offset & we will delete anything prior to then.
+ *
+ * @return string
+ */
+ protected static function getRefreshDateTime() {
+ return date('Ymdhis', strtotime("+ " . self::smartGroupCacheTimeout() . " Minutes"));
+ }
+
}
#CRM-17967 - Allow conact image file name length during upload up to 255 characters long
ALTER TABLE `civicrm_contact` CHANGE `image_URL` `image_URL` VARCHAR(512) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'optional URL for preferred image (photo, logo, etc.) to display for this contact.';
+-- CRM-18516 Convert the date fields relating to group caching and acl caching timestamp
+ALTER TABLE civicrm_group CHANGE cache_date cache_date timestamp NULL DEFAULT NULL , CHANGE refresh_date refresh_date timestamp NULL DEFAULT NULL;
+ALTER TABLE civicrm_acl_cache CHANGE modified_date modified_date timestamp NULL DEFAULT NULL;
+
-- CRM-18537
DELETE FROM civicrm_state_province WHERE name = 'Fernando de Noronha';
return $format;
}
- /**
- * Get the time in UTC for the current time. You can optionally send an offset from the current time if needed
- *
- * @param int $offset
- * the offset from the current time in seconds.
- *
- * @return string
- * the time in UTC
- */
- public static function getUTCTime($offset = 0) {
- $originalTimezone = date_default_timezone_get();
- date_default_timezone_set('UTC');
- $time = time() + $offset;
- $now = date('YmdHis', $time);
- date_default_timezone_set($originalTimezone);
- return $now;
- }
-
-
/**
* @param $date
* @param $dateType
<field>
<name>modified_date</name>
<title>Cache Modified Date</title>
- <type>date</type>
+ <type>timestamp</type>
<comment>When was this cache entry last modified</comment>
<add>1.6</add>
</field>
</field>
<field>
<name>cache_date</name>
- <type>datetime</type>
+ <type>timestamp</type>
<title>Group Cache Date</title>
<comment>Date when we created the cache for a smart group</comment>
<add>2.1</add>
</field>
<field>
<name>refresh_date</name>
- <type>datetime</type>
+ <type>timestamp</type>
<title>Next Group Refresh Time</title>
<comment>Date and time when we need to refresh the cache next.</comment>
<add>4.3</add>