diff --git a/ctools.module b/ctools.module index 374a10ac8f87447fe41ecebd6f2f822f49e63b86..b85995db354eaea307af0ab0cd3ba5cb960e24bf 100644 --- a/ctools.module +++ b/ctools.module @@ -146,3 +146,15 @@ function ctools_access_menu($access) { ctools_include('context'); return ctools_access($access, $contexts); } + +/** + * Implementation of hook_cron. Clean up old caches. + */ +function ctools_cron() { + if (variable_get('ctools_last_cron', 0) < time() - 86400) { + variable_set('ctools_last_cron', time()); + ctools_include('object-cache'); + ctools_object_cache_cron(); + } +} + diff --git a/includes/object-cache.inc b/includes/object-cache.inc index 1cd4bc4b773997f21d04342eeb3723ad94c952b8..493567a6841b96b539ef2d64518b31097a8a0f95 100644 --- a/includes/object-cache.inc +++ b/includes/object-cache.inc @@ -120,3 +120,11 @@ function ctools_object_cache_clean($age = NULL) { function ctools_object_cache_test($obj, $name) { return db_fetch_object(db_query("SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid != '%s' AND c.obj = '%s' AND c.name = '%s' ORDER BY c.updated ASC", session_id(), $obj, $name)); } + +/** + * Clean up old cached items on cron. + */ +function ctools_object_cache_cron() { + // delete anything 7 days old or more. + db_query("DELETE FROM {ctools_object_cache} WHERE timestamp < %d", time() - (86400 * 7)); +} diff --git a/plugins/contexts/user.inc b/plugins/contexts/user.inc index 6d2e16f801b1425a8108a6ea13b7902730d1b7bc..7a06f19cb9a5690ae89c5d4a02be1633d28f04d9 100644 --- a/plugins/contexts/user.inc +++ b/plugins/contexts/user.inc @@ -42,7 +42,7 @@ function ctools_context_create_user($empty, $data = NULL, $conf = FALSE) { if (!empty($data)) { $context->data = $data; - $context->title = $data->name; + $context->title = isset($data->name) ? $data->name : t('Anonymous'); $context->argument = $data->uid; return $context; }