MartinD, Petr, $otherrolesexperts
Working on enrol/database, I want to process a couple hundred thousand user roles and speeding things up...
My initial question was: what is the right way of changing role? unassign()
/assign()
? Is this required?. Looking at those functions, I see a lot of code, including callbacks to modules, and one call to sync_metacourses per enrolment. Ouch.
I was under the impression that role_assign() was a core function -- rather than a surface / UI function. Hmmm. We need _core functions in key areas of Moodle like roles to be fast fast *fast* _ ... so I'm going to be working on the following ideas:
- All the checking
role_assign()
is doing is insane and extremely costly. By the time any codepath reachesrole_assign()
they better have checked courseid, userid, and the phase of the moon. Can I excise those? I'll probably write role_assign_f() where f stands for fast and it assumes the caller has performed the relevant sanity checks. - Similarly, the fast version skips
sync_metacourses()
- I don't think anyone has been told about these new functions
$modulename_role_assign()
. So... before anyone uses them, can we change the semantics so we can call them after all the assignments have been done, with the timemodified they have to scan for? - Same for
unassign
, naturally
Overall - I think it'll be a good idea to define what the public API of accesslib is, and how it should be used. So we can tweak how things work inside for performance and fuzzy bunnies.