Permalink
Browse files

Made some fixes to get_course_users to make it use particular fields …

…passed

to it as before the recent changes.  This was causing blowout in memory
in the logs for large sites.

http://moodle.org/mod/forum/discuss.php?d=12236

I've done light testing of this only on a small site, I'm about to test it on
some bigger sites.
  • Loading branch information...
1 parent 527ef6b commit 00067b083652aba922b90d8f3dcab8d61865cfc8 moodler committed Sep 8, 2004
Showing with 7 additions and 14 deletions.
  1. +3 −10 course/lib.php
  2. +4 −4 lib/datalib.php
View
@@ -32,13 +32,7 @@ function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0,
// Get all the possible users
$users = array();
- if ($course->category) {
- $courseusers = get_course_users($course->id);
- } else {
- $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname");
- }
-
- if ($courseusers) {
+ if ($courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname')) {
foreach ($courseusers as $courseuser) {
$users[$courseuser->id] = fullname($courseuser, $isteacher);
}
@@ -266,9 +260,8 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
'WHERE us.course='.$course->id.' AND gm.groupid='.$selectedgroup.
' AND (gm.userid=us.userid OR gm.userid=ut.userid) AND gm.userid=u.id';
$courseusers = get_records_sql($sql);
- }
- else {
- $courseusers = get_course_users($course->id);
+ } else {
+ $courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname');
}
} else {
$courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname");
View
@@ -1317,7 +1317,7 @@ function get_course_teachers($courseid, $sort="t.authority ASC", $exceptions='')
*
* @param type description
*/
-function get_course_users($courseid, $sort="timeaccess DESC", $exceptions='') {
+function get_course_users($courseid, $sort="timeaccess DESC", $exceptions='', $fields='*') {
/// Using this method because the single SQL is too inefficient
// Note that this has the effect that teachers and students are
@@ -1326,7 +1326,7 @@ function get_course_users($courseid, $sort="timeaccess DESC", $exceptions='') {
if (!$teachers = get_course_teachers($courseid, $sort, $exceptions)) {
$teachers = array();
}
- if (!$students = get_course_students($courseid, $sort, "", 0, 99999, "", "", NULL, "", '', $exceptions)) {
+ if (!$students = get_course_students($courseid, $sort, '', 0, 99999, '', '', NULL, '', $fields, $exceptions)) {
$students = array();
}
@@ -1416,9 +1416,9 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
*
* @param type description
*/
-function get_site_users($sort="u.lastaccess DESC", $select="", $exceptions='') {
+function get_site_users($sort="u.lastaccess DESC", $fields='*', $exceptions='') {
- return get_course_users(SITEID, $sort, '', 0, 999999, '', '', NULL, '', $select, $exceptions);
+ return get_course_users(SITEID, $sort, $exceptions, $fields);
}

0 comments on commit 00067b0

Please sign in to comment.