Remember password for course guest access and reuse it if the enrol cache is reset. Do not print guest access form when already using guest course access.
Refactoring and improvements of the accesslib.php library including prevention of access for not-logged-in users when forcelogin enabled, improved context caching, OOP refactoring of contexts, fixed context loading, deduplication of role definitions in user sessions, installation improvements, decoupling of enrolment checking from capability loading, added detection of deleted and non-existent users in has_capability(), new function accesslib test, auth and enrol upgrade notes.
More details are available in tracker subtasks.
As part of this patch I also introduced a new method in accesslib can_access_course that can be used
to check a users access to a course.
I also fixed a minor issue with guest access flag caching in require_login