From 70981363bfd82165896bd345a2e2d8e853ec1a1e Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:56:30 +0000 Subject: [PATCH] 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. --- lib/accesslib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 539de87ac0..8d6685f08b 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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; } -- 2.39.5