mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
accesslib: get_dirty_contexts() - fix race condition, forget about CAST()s
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.
This commit is contained in:
parent
99be2a7fad
commit
70981363bf
@ -4578,7 +4578,7 @@ function get_dirty_contexts($time) {
|
||||
$sql = "SELECT name, value
|
||||
FROM {$CFG->prefix}config_plugins
|
||||
WHERE plugin='accesslib/dirtycontexts'
|
||||
AND CAST(value AS DECIMAL) > $time";
|
||||
AND value > ($time - 2)";
|
||||
if ($ctx = get_records_sql($sql)) {
|
||||
return $ctx;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user