MDL-35257 lib: if $CFG->logguests is disabled, avoid some log actions
authorDan Poltawski <dan@moodle.com>
Wed, 5 Sep 2012 02:34:51 +0000 (10:34 +0800)
committerDan Poltawski <dan@moodle.com>
Fri, 7 Sep 2012 02:24:50 +0000 (10:24 +0800)
This is for performance, else there can be great contention on the guest
user record as we've seen on moodle.org.

lib/datalib.php
lib/moodlelib.php

index 99f6b91..dde0f20 100644 (file)
@@ -1764,6 +1764,11 @@ function user_accesstime_log($courseid=0) {
         return;
     }
 
+    if (isguestuser()) {
+        // Do not update guest access times/ips for performance.
+        return;
+    }
+
     if (empty($courseid)) {
         $courseid = SITEID;
     }
index 1c8f966..1d10587 100644 (file)
@@ -3289,6 +3289,11 @@ function get_user_key($script, $userid, $instance=null, $iprestriction=null, $va
 function update_user_login_times() {
     global $USER, $DB;
 
+    if (isguestuser()) {
+        // Do not update guest access times/ips for performance.
+        return true;
+    }
+
     $now = time();
 
     $user = new stdClass();