The changes introduced here are completely safe, just we stop
binding SITEID and, instead, embed it in the SQL.
Why? Because Oracle 21 has started to return non-sense results
when SITEID is bound.
After lots of tests, attempts, debugging... we have been unable
to find any logic to the need of this change and also, have been
unable to reproduce the problem with a standalone script that
pretty much runs the same queries that the ones changed here.
I'm sure that there is something, somewhere, but have failed
to find it, grrr.
Please read MDL-75208 and linked issues to find more information
about this problem, that is one of the biggest mysteries I've
seen recently. Maybe at the end there is a tiny detail that
explains it all, but it's really well hidden.
By rounding the current time it was possible that the most recently
created user enrolments (e.g. self enrolments) were being excluded.
This would manifest itself in a user being enrolled on a course,
but it not appearing under "My courses" navigation or on their own
Dashboard until the rounded time had caught up with the current
time.
A new optional parameter $context has been added to the
core_group::groups_get_members_join() function.
Besides, some core_group methods now accept -1 (USERSWITHOUTHGROUP) for
the groupid field.
Similarly to what the previous patch does, we now change the default
sorting in functions enrol_get_users_courses() and
enrol_get_all_users_courses() too.
The patch also adds missing phpDocs for the functions, improves the
readability of some existing bits and mentions the changes in the
enrol/upgrade.txt file.
The new default value (null) now respects the navsortmycoursessort
behaviour and should be consistently used whenever we are displaying the
courses in the UI.
The function groups_get_user_groups is called too often both before rendering the page and after the page is rendered (using ajax).
The function was executing a query joining 3 tables in each call. The plementation of the function has now modified to store the
query result in a request cache.
* New optional parameter $enrolid for the following functions:
- get_enrolled_join()
- get_enrolled_sql()
- get_enrolled_with_capabilities_join()
Setting this parameter to a non-zero value will add a condition
to the query such that only users that were enrolled with this
enrolment method will be returned.
Part of MDL-59290.