Issue Details (XML | Word | Printable)

Key: MDL-8785
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Martin Dougiamas
Reporter: Martin Dougiamas
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Remove timestart and timeend from consideration by load_user_capability()

Created: 07/Mar/07 12:15 PM   Updated: 30/Jan/08 04:20 PM
Return to search
Component/s: Enrolments, Roles
Affects Version/s: 1.7, 1.7.1, 1.7.2, 1.8
Fix Version/s: 1.7.2, 1.8

Issue Links:
Relates

Participants: Eloy Lafuente (stronk7), Martin Dougiamas and Martín Langhoff
Security Level: None
Resolved date: 07/Mar/07
Affected Branches: MOODLE_17_STABLE, MOODLE_18_STABLE
Fixed Branches: MOODLE_17_STABLE, MOODLE_18_STABLE


 Description  « Hide
Eloy has correctly identified timestart and timeend as a big database bottleneck in load_user_capability because they prevent caching and deal with inequalities, so let's get rid if them!

These times specify the duration that the enrolment is active. Currently they are only used by self-enrolling courses where the course has a duration. In these instance timestart is set to now and timeend is set to some time in the future. Zero in timestart means inifinite past, and in timeend means inifinite future.

We were checking these to cope with all cases where people might want to set enrolment durations starting and ending in the future, but this is actually not very useful. Let's let the enrolment plugins handle such things (adding role assignments on the fly where necessary).

So instead, I propose:

1) We remove the time checks completely from load_user_capability and assume all role assigments in the database are valid.

2) We add a cron check to delete any role assignments where (timeend > 0 AND timeend < $now)

3) We make sure this is documented well in the code and on the wiki.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
moodler committed 2 files to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 07/Mar/07 01:54 PM
Fixes to remove timestart and timeend from consideration when loading user capabilities

Instead, we delete role assignments in cron

This is resulting in a great speed increase! MDL-8785

Thanks Eloy for the idea!
MODIFY lib/accesslib.php   Rev. 1.221.2.16    (+6 -9 lines)
MODIFY admin/cron.php   Rev. 1.98.2.4    (+16 -2 lines)
moodler committed 2 files to 'Moodle CVS' - 07/Mar/07 01:56 PM
Merged fixes for MDL-8785 from 1.8 to head
MODIFY admin/cron.php   Rev. 1.102    (+16 -2 lines)
MODIFY lib/accesslib.php   Rev. 1.237    (+6 -9 lines)
moodler committed 2 files to 'Moodle CVS' on branch 'MOODLE_17_STABLE' - 07/Mar/07 02:00 PM
Merged fixes for MDL-8785 from 1.8

BIG SPEED INCREASE!!!!!!
MODIFY lib/accesslib.php   Rev. 1.166.2.40    (+0 -4 lines)
MODIFY admin/cron.php   Rev. 1.89.2.6    (+16 -2 lines)