Fixed longtimenosee unenrolments. user_lastaccess and role_assignments were growing with uneccessary entries, to the point where memory limits were reached and in the end NO unenrolments were happening at all.

See  MDL-11571
This commit is contained in:
moodler 2007-10-03 12:24:06 +00:00
parent ece966f06e
commit 1afb11e70b
2 changed files with 4 additions and 5 deletions

View File

@ -199,8 +199,8 @@
if ($assigns = get_users_longtimenosee($longtime)) {
foreach ($assigns as $assign) {
if ($context = get_context_instance(CONTEXT_COURSE, $assign->courseid)) {
if (role_unassign(0, $assign->id, 0, $context->id)) {
mtrace("Deleted assignment for user $assign->id from course $assign->courseid");
if (role_unassign(0, $assign->userid, 0, $context->id)) {
mtrace("Deleted assignment for user $assign->userid from course $assign->courseid");
}
}
}
@ -474,4 +474,4 @@
echo "</xmp>";
}
?>
?>

View File

@ -354,10 +354,9 @@ function get_users_unconfirmed($cutofftime=2000000000) {
*/
function get_users_longtimenosee($cutofftime) {
global $CFG;
return get_records_sql("SELECT userid as id, courseid
return get_records_sql("SELECT id, userid, courseid
FROM {$CFG->prefix}user_lastaccess
WHERE courseid != ".SITEID."
AND timeaccess > 0
AND timeaccess < $cutofftime ");
}