]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: get_dirty_contexts() - fix race condition, forget about CAST()s
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:56:30 +0000 (07:56 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:56:30 +0000 (07:56 +0000)
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

index 539de87ac034e439d73960c168508f2bcaf4d862..8d6685f08ba4409e103c056164a5b744ff7afc46 100755 (executable)
@@ -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;
     }