-
Improvement
-
Resolution: Fixed
-
Major
-
1.9, 1.9.1
-
None
-
MySQL
-
MOODLE_19_STABLE
-
MOODLE_20_STABLE
I explain my problem :
The function role_assign is really heavy.
I made a development to enrol students automatically in their course spaces and groups (it's a synchronization with LDAP).
When I call the function role_assign (or role_unassign it's the same problem), to enrol 186 students in a group and in a context of a course, it takes 213 secs!
So, I tried to understand why before I post in this forum and I think I have a possible reason:
I duplicated the function role_assign in a personalized function called role_assign_iut and I just commented the lines :
/// Do some data validation
if (empty($roleid))
{ debugging('Role ID not provided'); return false; }if (empty($userid) && empty($groupid))
{ debugging('Either userid or groupid must be provided'); return false; }if ($userid && !record_exists('user', 'id', $userid))
{ debugging('User ID '.intval($userid).' does not exist!'); return false; }if ($groupid && !groups_group_exists($groupid))
{ debugging('Group ID '.intval($groupid).' does not exist!'); return false; }if (!$context = get_context_instance_by_id($contextid))
{ debugging('Context ID '.intval($contextid).' does not exist!'); return false; }if (($timestart and $timeend) and ($timestart > $timeend))
{ debugging('The end time can not be earlier than the start time'); return false; }So now, the execution time takes only 2secs!
I just commented these lines because I know my parameters are good, I checked them before the execution.
My questions are :
Why these params verifications takes so long?
Why are these verifications here?
Is it just to be sure the developers like me don't use bad params?
Regards,
MELIX Simon
- has been marked as being related by
-
MDL-17949 List of problems related to potential enrolment rewrite in 2.0 - META
- Closed