]> git.mjollnir.org Git - moodle.git/commitdiff
If there aren't many logs to process, then do it now during the main
authormoodler <moodler>
Tue, 3 Feb 2004 04:56:22 +0000 (04:56 +0000)
committermoodler <moodler>
Tue, 3 Feb 2004 04:56:22 +0000 (04:56 +0000)
upgrade, but otherwise, tell the upgrader to run the separate script
at admin/upgrade_logs.php later on.

lib/db/mysql.php
lib/db/postgres7.php

index 5adf3e8142dcc9ea986c529bc28ad926d2972385..f43738dce0c64621a54c20cfc430f313bbefb3a9 100644 (file)
@@ -637,36 +637,39 @@ function main_upgrade($oldversion=0) {
     if ($oldversion < 2004013101) {
         table_column("log", "", "cmid", "integer", "10", "unsigned", "0", "", "module");
 
-        /// try and extract as many cmids as possible from the existing logs
 
         if ($coursemodules = get_records_sql("SELECT cm.*, m.name 
                                                 FROM {$CFG->prefix}course_modules cm, 
                                                      {$CFG->prefix}modules m
                                                 WHERE cm.module = m.id")) {
+
             $cmcount = count($coursemodules);
-            if ($cmcount > 10) {
+
+            if ($cmcount > 10) {   /// Process the logs later
                 print_simple_box_start("center", "", "#ffcccc");
-                echo '<font size="+1">';
-                echo "<p>Upgrading old logs with new data from $cmcount coursemodules.";
-                echo '<p>This process may take a very long time ... please be patient and let it finish.';
-                echo '</font>';
+                echo '<p>Your old logs may need to be upgraded to take advantage of some new features.';
+                echo 'To upgrade your logs, go to this page AFTER Moodle is completely upgraded:</p>';
+                echo "<p>  $CFG->wwwroot/$CFG->admin/upgrade_logs.php</p>";
                 print_simple_box_end();
-            }
-            foreach ($coursemodules as $cm) {
-                execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
-                             WHERE module = '$cm->name' AND url LIKE 'view.php?id=$cm->id%'");
-                if ($cm->name == "forum") {
+
+            } else {               /// Process the logs now (there aren't that many)
+                notify("Upgrading old logs with new data from $cmcount coursemodules.");
+                foreach ($coursemodules as $cm) {
                     execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
-                                 WHERE module = 'forum' AND url LIKE '%?f=$cm->instance%'");
-                    if ($discussions = get_records("forum_discussions", "forum", $cm->instance)) {
-                        notify("Processing ".count($discussions)." discussions");
-                        foreach ($discussions as $discussion) {
-                            execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
-                                         WHERE module = 'forum' AND url LIKE '%?d=$discussion->id%'");
+                                 WHERE module = '$cm->name' AND url LIKE 'view.php?id=$cm->id%'");
+                    if ($cm->name == "forum") {
+                        execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
+                                     WHERE module = 'forum' AND url LIKE '%?f=$cm->instance%'");
+                        if ($discussions = get_records("forum_discussions", "forum", $cm->instance)) {
+                            notify("Processing ".count($discussions)." discussions");
+                            foreach ($discussions as $discussion) {
+                                execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
+                                             WHERE module = 'forum' AND url LIKE '%?d=$discussion->id%'");
+                            }
                         }
                     }
+                    flush();
                 }
-                flush();
             }
         }
     }
index 684b8b8c1845f048550d0d71df8663ed101d14e8..36bd38f050713519380a50988780664b13aa84cb 100644 (file)
@@ -383,31 +383,45 @@ function main_upgrade($oldversion=0) {
     if ($oldversion < 2004013101) {
         table_column("log", "", "cmid", "integer", "10", "unsigned", "0", "", "module");
 
-        /// try and extract as many cmids as possible from the existing logs
 
         if ($coursemodules = get_records_sql("SELECT cm.*, m.name 
                                                 FROM {$CFG->prefix}course_modules cm, 
                                                      {$CFG->prefix}modules m
                                                 WHERE cm.module = m.id")) {
-            foreach ($coursemodules as $cm) {
-                execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
-                             WHERE module = '$cm->name' AND url ILIKE 'view.php?id=$cm->id%'");
-                if ($cm->name == "forum") {
+
+            $cmcount = count($coursemodules);
+
+            if ($cmcount > 10) {   /// Process the logs later
+                print_simple_box_start("center", "", "#ffcccc");
+                echo '<p>Your old logs may need to be upgraded to take advantage of some new features.';
+                echo 'To upgrade your logs, go to this page AFTER Moodle is completely upgraded:</p>';
+                echo "<p>  $CFG->wwwroot/$CFG->admin/upgrade_logs.php</p>";
+                print_simple_box_end();
+
+            } else {               /// Process the logs now (there aren't that many)
+                notify("Upgrading old logs with new data from $cmcount coursemodules.");
+                foreach ($coursemodules as $cm) {
                     execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
-                                 WHERE module = 'forum' AND url ILIKE '%?f=$cm->instance%'");
-                    if ($discussions = get_records("forum_discussions", "forum", $cm->instance)) {
-                        foreach ($discussions as $discussion) {
-                            execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
-                                         WHERE module = 'forum' AND url ILIKE '%?d=$discussion->id%'");
+                                 WHERE module = '$cm->name' AND url ILIKE 'view.php?id=$cm->id%'");
+                    if ($cm->name == "forum") {
+                        execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
+                                     WHERE module = 'forum' AND url ILIKE '%?f=$cm->instance%'");
+                        if ($discussions = get_records("forum_discussions", "forum", $cm->instance)) {
+                            notify("Processing ".count($discussions)." discussions");
+                            foreach ($discussions as $discussion) {
+                                execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 
+                                             WHERE module = 'forum' AND url ILIKE '%?d=$discussion->id%'");
+                            }
                         }
                     }
+                    flush();
                 }
-                flush();
             }
         }
     }
-    
+
     return $result;
+
 }
 
-?>    
+?>