Commit 07cd46d8 authored by Petr Skoda's avatar Petr Skoda Committed by Eloy Lafuente
Browse files

MDL-25674 detection of invalid $user parameter when synchronising user enrolments

parent c35ae136
......@@ -81,6 +81,15 @@ class enrol_database_plugin extends enrol_plugin {
$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])) {
......
......@@ -136,6 +136,15 @@ class enrol_ldap_plugin extends enrol_plugin {
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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment