Skip to content

Commit

Permalink
MDL-63716 course: less user_accesstime_log() calls
Browse files Browse the repository at this point in the history
We should only call this function when a user actually views a course. It is not called
automatically when a course context is validated from a webservice. It is called directly
from the core_course_view_course webservice.
  • Loading branch information
Damyon Wiese committed Nov 12, 2018
1 parent 208950c commit 160e77f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/datalib.php');
require_once($CFG->dirroot.'/course/format/lib.php');

define('COURSE_MAX_LOGS_PER_PAGE', 1000); // Records.
Expand Down Expand Up @@ -3665,6 +3666,8 @@ function course_view($context, $sectionnumber = 0) {

$event = \core\event\course_viewed::create($eventdata);
$event->trigger();

user_accesstime_log($context->instanceid);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2763,7 +2763,10 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
$PAGE->set_course($course);
}
// Set accesstime or the user will appear offline which messes up messaging.
user_accesstime_log($course->id);
// Do not update access time for webservice or ajax requests.
if (!WS_SERVER && !AJAX_SCRIPT) {
user_accesstime_log($course->id);
}
return;
}

Expand Down Expand Up @@ -2972,7 +2975,10 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
}

// Finally access granted, update lastaccess times.
user_accesstime_log($course->id);
// Do not update access time for webservice or ajax requests.
if (!WS_SERVER && !AJAX_SCRIPT) {
user_accesstime_log($course->id);
}
}


Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ the groupid field.
until all settings have been set. The additional parameters are used recursively and shouldn't be need to be explicitly passed in when calling
the function from other parts of Moodle.
The return value: $settingsoutput is an array of setting names and the values that were set by the function.
* Webservices no longer update the lastaccess time for a user in a course. Call core_course_view_course() manually if needed.

=== 3.5 ===

Expand Down

0 comments on commit 160e77f

Please sign in to comment.