]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: dirty context handling now uses cache_flags
authormartinlanghoff <martinlanghoff>
Tue, 2 Oct 2007 08:46:27 +0000 (08:46 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 2 Oct 2007 08:46:27 +0000 (08:46 +0000)
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.

lib/accesslib.php

index d3291249c5175a5e2794ba2a529e59c9ccf7b226..3ffbc57b651f39c1d966e8d98b49da1276466def 100755 (executable)
@@ -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