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:
martinlanghoff 2007-09-19 07:56:30 +00:00
parent 99be2a7fad
commit 70981363bf

View File

@ -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;
}