Index: store/store.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ecommerce/store/store.install,v
retrieving revision 1.20.2.1.2.13
diff -u -p -r1.20.2.1.2.13 store.install
--- store/store.install	9 Feb 2007 12:41:40 -0000	1.20.2.1.2.13
+++ store/store.install	10 Feb 2007 05:45:09 -0000
@@ -413,7 +413,7 @@ function store_update_21() {
     'state',
     'country',
   );
-  if (!isset($_SESSION['store_update_18_txnid'])) {
+  if (!isset($_SESSION['store_update_21_count'])) {
     // Create New Table
     switch($GLOBALS['db_type']) {
       case 'mysql':
@@ -436,15 +436,15 @@ function store_update_21() {
         break;
     }
     
-    $_SESSION['store_update_18_txnid'] = 0;
-    $_SESSION['store_update_18_max'] = db_query('SELECT MAX(txnid) FROM {ec_transaction}');
+    $_SESSION['store_update_21_count'] = 0;
+    $_SESSION['store_update_21_total'] = db_query('SELECT COUNT(txnid) FROM {ec_transaction}');
     // Return query info
     $ret['#finished'] = 0;
     return $ret;
   }    
 
   // Do work
-  $result = db_query_range('SELECT * FROM {ec_transaction} ORDER BY txnid ASC', $_SESSION['store_update_18_txnid'], 20);
+  $result = db_query_range('SELECT * FROM {ec_transaction} ORDER BY txnid ASC', $_SESSION['store_update_21_count'], 20);
   while ($txn = db_fetch_object($result)) {
     // Merge in billing and shipping addresses
     foreach (array('billing', 'shipping') as $address_type) {
@@ -464,14 +464,14 @@ function store_update_21() {
       }
       db_query('INSERT INTO {ec_transaction_address} ('. implode(', ', $k) .') VALUES('. implode(', ', $s) .')', $v);
       $k = $v = $s = array();
-      $_SESSION['store_update_18_txnid'] = $txn->txnid;
     }
+    ++$_SESSION['store_update_21_count'];
   }
   
   // See if we are done.
-  if ($_SESSION['store_update_18_txnid'] < $_SESSION['store_update_18_max']) {
+  if ($_SESSION['store_update_21_count'] < $_SESSION['store_update_21_total']) {
     // Not done yet. Return the progress.
-    return array('#finished' => $_SESSION['store_update_18_txnid'] / $_SESSION['store_update_18_max']);
+    return array('#finished' => $_SESSION['store_update_21_count'] / $_SESSION['store_update_21_total']);
   }
   else {
     // Done. Clean up and indicate we're finished.
@@ -492,8 +492,8 @@ function store_update_21() {
     $ret[] = update_sql("ALTER TABLE {ec_transaction} DROP billing_zip");
     $ret[] = update_sql("ALTER TABLE {ec_transaction} DROP billing_country");
     $ret['#finished'] = 1;
-    unset($_SESSION['store_update_18_txnid']);
-    unset($_SESSION['store_update_18_max']);
+    unset($_SESSION['store_update_21_count']);
+    unset($_SESSION['store_update_21_total']);
     return $ret;
   }
 }
