Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

My Moodle/Courses: MDL-20472 get_my_courses returns 2 more courses th…

…en limit. Repairs two off by one errors in get_my_courses and get_user_courses_bycap.
  • Loading branch information...
commit bd1f93687d587952994a2acecab6c3d3e84083eb 1 parent 5ec6bef
ericmerrill authored
Showing with 8 additions and 4 deletions.
  1. +4 −2 lib/accesslib.php
  2. +4 −2 lib/datalib.php
View
6 lib/accesslib.php
@@ -1118,10 +1118,12 @@ function get_user_courses_bycap($userid, $cap, $accessdata, $doanything, $sort='
$c = make_context_subobj($c);
if (has_capability_in_accessdata($cap, $c->context, $accessdata, $doanything)) {
- $courses[] = $c;
- if ($limit > 0 && $cc++ > $limit) {
+ if ($limit > 0 && $cc >= $limit) {
break;
}
+
+ $courses[] = $c;
+ $cc++;
}
}
rs_close($rs);
View
6 lib/datalib.php
@@ -916,10 +916,12 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
// build the context obj
$c = make_context_subobj($c);
- $courses[$c->id] = $c;
- if ($limit > 0 && $cc++ > $limit) {
+ if ($limit > 0 && $cc >= $limit) {
break;
}
+
+ $courses[$c->id] = $c;
+ $cc++;
}
rs_close($rs);
return $courses;
Please sign in to comment.
Something went wrong with that request. Please try again.