Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-25674 detection of invalid $user parameter when synchronising use…

…r enrolments
  • Loading branch information...
commit 07cd46d84dd8efc8574b695513ceb6b4cdae22c5 1 parent c35ae13
@skodak skodak authored stronk7 committed
Showing with 18 additions and 0 deletions.
  1. +9 −0 enrol/database/lib.php
  2. +9 −0 enrol/ldap/lib.php
View
9 enrol/database/lib.php
@@ -81,6 +81,15 @@ public function sync_user_enrolments($user) {
$ignorehidden = $this->get_config('ignorehiddencourses');
+ if (!is_object($user) or !property_exists($user, 'id')) {
+ throw new coding_exception('Invalid $user parameter in sync_user_enrolments()');
+ }
+
+ if (!property_exists($user, $localuserfield)) {
+ debugging('Invalid $user parameter in sync_user_enrolments(), missing '.$localuserfield);
+ $user = $DB->get_record('user', array('id'=>$user->id));
+ }
+
// create roles mapping
$allroles = get_all_roles();
if (!isset($allroles[$defaultrole])) {
View
9 enrol/ldap/lib.php
@@ -136,6 +136,15 @@ public function sync_user_enrolments($user) {
return;
}
+ if (!is_object($user) or !property_exists($user, 'id')) {
+ throw new coding_exception('Invalid $user parameter in sync_user_enrolments()');
+ }
+
+ if (!property_exists($user, 'idnumbner')) {
+ debugging('Invalid $user parameter in sync_user_enrolments(), missing idnumber');
+ $user = $DB->get_record('user', array('id'=>$user->id));
+ }
+
// We may need a lot of memory here
@set_time_limit(0);
raise_memory_limit(MEMORY_HUGE);
Please sign in to comment.
Something went wrong with that request. Please try again.