From: martinlanghoff Date: Tue, 2 Oct 2007 08:46:27 +0000 (+0000) Subject: accesslib: dirty context handling now uses cache_flags X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5903fbf5e7f0cc4782db3ac3f78919b936d33c1c;p=moodle.git accesslib: dirty context handling now uses cache_flags get_dirty_contexts() and mark_context_dirty() now use cache_flags infrastructure. Remove deprecated cleanup_dirty_contexts() - this is now handled by gc_cache_flags() in a more generic way. --- diff --git a/lib/accesslib.php b/lib/accesslib.php index d3291249c5..3ffbc57b65 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -4718,20 +4718,11 @@ function make_context_subobj($rec) { * Fetch recent dirty contexts to know cheaply whether our $USER->access * is stale and needs to be reloaded. * - * Uses config_plugins. + * Uses cache_flags * */ function get_dirty_contexts($time) { - global $CFG; - - $sql = "SELECT name, value - FROM {$CFG->prefix}config_plugins - WHERE plugin='accesslib/dirtycontexts' - AND value > ($time - 2)"; - if ($ctx = get_records_sql($sql)) { - return $ctx; - } - return array(); + return get_cache_flags('accesslib/dirtycontexts', $time-2); } /* @@ -4740,28 +4731,13 @@ function get_dirty_contexts($time) { * */ function mark_context_dirty($path) { - + global $CFG; // only if it is a non-empty string if (is_string($path) && $path !== '') { - set_config($path, time(), 'accesslib/dirtycontexts'); + set_cache_flag('accesslib/dirtycontexts', $path, 1, time()+$CFG->sessiontimeout); } } -/* - * Cleanup all the old/stale dirty contexts. - * Any context exceeding our session - * timeout is stale. We only keep these for ongoing - * sessions. - * - */ -function cleanup_dirty_contexts() { - global $CFG; - - $sql = "plugin='accesslib/dirtycontexts' AND - value < " . time() - $CFG->sessiontimeout; - delete_records_select('config_plugins', $sql); -} - /* * Will walk the contextpath to answer whether * the contextpath is clean