A bit of cleanup on the SQL we use for updates. Unfortunately, MySQL
uses non-SQL-standard syntax for updates reading or updating multiple
tables. After much testing across Pg and MySQL, I boiled it down to
the minimal differences -- but we still have different SQL.
The timings for this on a large reference install, calling
build_context_path(true):
- MySQL incompatible 1s
- Petr's fixes 60s -- DB complains of too many writes
- This commit 24s -- DB complains of too many writes
Also - fixed a remaining problem with $emptyclause
Affects MDL-11347
In one tiny patch we do two things.
First, we fix the race condition around dirty context and accessdata
timestamps -- it is saner to offset the check than to offset the
recording of the change (as an earlier patch did).
On a cluster, you still need NTP.
Second, we do away with CAST(). Ideally, the values should be compared
as ints but it's hard to get a CAST() syntax that is portable enough
to work on all our supported DBs. And Eloy pointed out (and I
corroborated testing) that we'll never have problems with the string
length, as our timestamps are always 10 chars as a string... and the
day they go to 11 chars we'll hit the unix Year-2038 bug.
Blocks not on the coursepage should have their context "hanging" from the
site context. get_context_instance() was doing this correctly, but not
build_context_path().
Memory usage was still high for long userlists. Use recordsets
to manage memory growth.
Note that we are still collecting a long long HTML table in memory
before we print it, so the footprint of the html itself is bit of an
issue.
With this patch, we fetch participants contexts in the main search
query. This cuts 1DBq per participant for the display.
Might fix MDL-11222 'global teacher viewing participants issues' where
we are getting OOM'd with many users.
make_context_subobj() was not providing a contextlevel property, and
no callers fetched the field. This comes from its humble origins where
it was only ever called for course objects. These days it's used in
many other situations, so this patch DTRT and
- fixes make_context_subobj() expect a cxtlevel and turn it into
contextlevel
- fixes all callers (accesslib, datalib) to provide it
Having no roles set as coursemanager is a valid setting.
get_courses_wmanagers() should not produce invalid SQL on it...
actually, it should not even try to get the course managers.
The SQL query that would fetch rdefs not associated with any ra was
not being executed. Duh! For example, a user with a teacher RA sitewide
would never be affected by a role override at the category
level, because it was not being loaded into accessdata.
get_user_access_bycontext() was narrowing down too much the rdefs it
was fetching. With this patch, it now correctly retrieves the rdefs for
new roles assigned in lower contexts, and also correctly retrieves
rdefs present in the course context (fixing MDL-11220).
This also means that we now do the job in 2 DB queries (instead of 3),
and we move a bit more data, but those rows are actually needed ;-)
Showing the calendar block was causing 2 DB queries per course the
user is enrolled in. Instead, use the data available in the array that
is passed as a parameter, and spare the DB a ton of needless traffic.
Fixes MDL-11221 Calendar not using context stuff from get_my_courses
Author: Martin Dougiamas
Very last caller to rebuild_context_rel() and any XX_context_rel()
function. move_category() already takes care of calling
context_moved(), which does the required context.path maintenance.
Addresses MDL-11219
Prevent calls to has_capability() in build_navigation() from messing
with upgrades.
Most calls to has_capability() in weblib should be moved to the callers.
Fix a thinko in a variable assignment that prevented us from grabbing
the correct roles as managers. Addresses Yu's report at
MDL-11182 admin shows up as teacher.