]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13316 added static cache for time zone info; merged from MOODLE_19_STABLE
authorskodak <skodak>
Sun, 3 Feb 2008 16:01:33 +0000 (16:01 +0000)
committerskodak <skodak>
Sun, 3 Feb 2008 16:01:33 +0000 (16:01 +0000)
lib/moodlelib.php

index 3532b6637c2b7e8001807e7535278b1407b81111..bfed92f00921ccd6566172200fc36a866306d5bb 100644 (file)
@@ -1473,8 +1473,12 @@ function calculate_user_dst_table($from_year = NULL, $to_year = NULL) {
     // Also, the array is sorted in descending timestamp order!
 
     // Get DB data
-    $presetrecords = get_records('timezone', 'name', $usertz, 'year DESC', 'year, gmtoff, dstoff, dst_month, dst_startday, dst_weekday, dst_skipweeks, dst_time, std_month, std_startday, std_weekday, std_skipweeks, std_time');
-    if(empty($presetrecords)) {
+
+    static $presets_cache = array();
+    if (!isset($presets_cache[$usertz])) {
+        $presets_cache[$usertz] = get_records('timezone', 'name', $usertz, 'year DESC', 'year, gmtoff, dstoff, dst_month, dst_startday, dst_weekday, dst_skipweeks, dst_time, std_month, std_startday, std_weekday, std_skipweeks, std_time');
+    }
+    if(empty($presets_cache[$usertz])) {
         return false;
     }
 
@@ -1485,7 +1489,7 @@ function calculate_user_dst_table($from_year = NULL, $to_year = NULL) {
     // Add all required change timestamps
     foreach($yearstoprocess as $y) {
         // Find the record which is in effect for the year $y
-        foreach($presetrecords as $year => $preset) {
+        foreach($presets_cache[$usertz] as $year => $preset) {
             if($year <= $y) {
                 break;
             }