Skip to content

Commit

Permalink
MDL-25674 detection of invalid $user parameter when synchronising use…
Browse files Browse the repository at this point in the history
…r enrolments
  • Loading branch information
skodak authored and stronk7 committed Dec 20, 2010
1 parent c35ae13 commit 07cd46d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions enrol/database/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
9 changes: 9 additions & 0 deletions enrol/ldap/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 07cd46d

Please sign in to comment.