Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.9, 1.9.1
-
Fix Version/s: 2.0
-
Component/s: Enrolments, Performance, Roles / Access
-
Labels:None
-
Environment:HideApache2 : Version : 2.2.8-3
PHP : Version : 5.2.5-3
MySQL : Version : 5.0.51a
System : Linux debian-test2 2.6.22-3-686 #1 SMP Mon Nov 12 08:32:57 UTC 2007 i686 GNU/Linux
Server config :
4 cores (3.06 GHz)
4 GB RAM
200GB HDDShowApache2 : Version : 2.2.8-3 PHP : Version : 5.2.5-3 MySQL : Version : 5.0.51a System : Linux debian-test2 2.6.22-3-686 #1 SMP Mon Nov 12 08:32:57 UTC 2007 i686 GNU/Linux Server config : 4 cores (3.06 GHz) 4 GB RAM 200GB HDD
-
Database:MySQL
-
Affected Branches:MOODLE_19_STABLE
-
Fixed Branches:MOODLE_20_STABLE
Description
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
Issue Links
| This issue has been marked as being related by: | ||||
| MDL-17949 | List of problems related to potential enrolment rewrite in 2.0 - META |
|
|
|
have you tried just commenting out individual validation functions?
(I would imagine the userrid/ groupid/ context checks would be the slow ones since they are likely to cause a db query per call)