Index: pift.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_test/pift.install,v
retrieving revision 1.14
diff -u -r1.14 pift.install
--- pift.install	27 Jun 2009 01:44:08 -0000	1.14
+++ pift.install	27 Jul 2009 22:57:20 -0000
@@ -113,6 +113,8 @@
  * Remove old variables.
  */
 function pift_update_6200() {
+  $ret = array();
+
   // List of old variables.
   $vars = array(
     'pift_server_sites',
@@ -135,6 +137,8 @@
   foreach ($vars as $var) {
     variable_del($var);
   }
+
+  return $ret;
 }
 
 /**
@@ -210,9 +214,12 @@
 /**
  * Update test records.
  */
-function pift_update_6202() {
-  $result = db_query('SELECT *
-                      FROM {pift_data}');
+function pift_update_6202(&$sandbox = NULL) {
+  if (!isset($sandbox['progress'])) {
+    $sandbox['progress'] = 0;
+    $sandbox['current_ftid'] = 0;
+    $sandbox['max'] = db_result(db_query('SELECT COUNT(ftid) FROM {pift_data}'));
+  }
 
   // Map of old status to equivilent new ones.
   $statuses = array(
@@ -223,29 +230,37 @@
     4 => 1, // PIFT_NOT_READABLE => PIFT_STATUS_QUEUE
   );
 
-  // Read in map of ftid => test_id provided from pifr server 1.x.
-  if (file_exists(drupal_get_path('module', 'pift') . '/files.dump.txt')) {
+  // Read in map of ftid => test_id provided from pifr server 1.x, in a comma
+  // delimited file of the format: file_id,ftid.
+  if ($lines = file('http://testing.drupal.org/files.dump.txt')) {
     $map = array();
-    $lines = file(drupal_get_path('module', 'pift') . '/files.dump.txt');
     foreach ($lines as $line) {
       $parts = explode(',', $line);
       $map[$parts[1]] = $parts[0];
     }
-  }
 
-  // Update old data and insert into test table.
-  $count = 0;
-  while ($test = db_fetch_object($result)) {
-    // Remove link from display data.
-    $message = preg_replace('/\s+(<a|a) href.*?$/', '', $test->display_data);
-
-    $ret[] = update_sql("INSERT INTO {pift_test} (test_id, type, id, status, message, last_tested)
-                         VALUES (%d, %d, %d, %d, '%s', %d)",
-                         $map[$test->ftid], PIFT_TYPE_FILE, $test->fid, $statuses[$test->status], $message, $test->timestamp);
-    $count++;
+    // Update old data and insert into test table.
+    $result = db_query_range('SELECT *
+                              FROM {pift_data}
+                              WHERE ftid > %d
+                              ORDER BY ftid ASC', $sandbox['ftid'], 0, 1000);
+    $count = 0;
+    while ($test = db_fetch_object($result)) {
+      // Remove link from display data.
+      $message = preg_replace('/\s+(<a|a) href.*?$/', '', $test->display_data);
+
+      db_query("INSERT INTO {pift_test} (test_id, type, id, status, message, last_tested)
+                VALUES (%d, %d, %d, %d, '%s', %d)",
+                $map[$test->ftid], PIFT_TYPE_FILE, $test->fid, $statuses[$test->status], $message, $test->timestamp);
+      $count++;
+      $sandbox['progress']++;
+      $sandbox['current_ftid'] = $test->ftid;
+    }
+
+    $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
   }
 
-  $new_count = db_result(db_query('SELECT COUNT() FROM {pift_test}'));
+  $new_count = db_result(db_query('SELECT COUNT(test_id) FROM {pift_test}'));
   return array(array('success' => $count == $new_count, 'query' => 'Update test records.'));
 }
 
@@ -254,6 +269,8 @@
  */
 function pift_update_6203() {
   $ret = array();
+
   $ret[] = update_sql('DROP TABLE {pift_data}');
+
   return $ret;
 }
