Index: active_translation.batch.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/active_translation/active_translation.batch.inc,v
retrieving revision 1.5
diff -u -p -r1.5 active_translation.batch.inc
--- active_translation.batch.inc	16 Jun 2008 20:25:32 -0000	1.5
+++ active_translation.batch.inc	19 Jun 2008 08:47:24 -0000
@@ -19,13 +19,13 @@ function active_translation_build_batch_
 
 function _active_translation_batch_operation(&$context) {
   if (empty($context['sandbox'])) {
-    watchdog('active_translation', 'Rebuilding the active translation table.');
+    watchdog('active_translation', 'Starting to rebuild the active translation table.');
 
     // Initiate multistep processing. Call language_list() and reset its cache.
     $context['sandbox']['languages'] = array_keys(language_list('language', TRUE));
     $context['sandbox']['progress'] = 0;
-    $context['sandbox']['current_translation'] = 1;
-    $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT tnid) FROM {node} WHERE tnid > 0'));
+    $context['sandbox']['current_translation'] = 0;
+    $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT tnid) FROM {node} WHERE tnid IS NOT NULL AND tnid > 0'));
 
     // Drop and recreate the database table to ensure the columns match the
     // current list of languages. Clear the cache to get rid of any cached
@@ -41,7 +41,11 @@ function _active_translation_batch_opera
       $fields[] = db_escape_table($lang_code);
       $values[] = 'nid';
     }
-    db_query('INSERT INTO {active_translation} (atid, '. implode(', ', $fields) .') SELECT DISTINCT(nid), '. implode(', ', $values) .' FROM {node} WHERE tnid = 0 ORDER BY tnid');
+    // We can't use db_placeholders() because we're using field names rather
+    // than values.
+    db_query('INSERT INTO {active_translation} (atid, '. implode(', ', $fields) .') SELECT DISTINCT(nid), '. implode(', ', $values) .' FROM {node} WHERE tnid = 0 OR tnid IS NULL ORDER BY tnid');
+
+    watchdog('active_translation', 'Created records for untranslated and language neutral nodes.');
   }
 
   // Process the next set of translations.
@@ -49,23 +53,30 @@ function _active_translation_batch_opera
   $result = db_query_range("SELECT DISTINCT tnid FROM {node} WHERE tnid > %d ORDER BY tnid ASC", $context['sandbox']['current_translation'], 0, $limit);
   while ($row = db_fetch_object($result)) {
     $node = node_load($row->tnid);
-    $translation = active_translation_recompute($node);
-    drupal_write_record('active_translation', $translation);
+    if (empty($node->nid)) {
+      watchdog('active_translation', 'Could not load the node %nid.', array('%nid' => $row->tnid), WATCHDOG_ERROR);
+    }
+    else {
+      $translation = active_translation_recompute($node);
+      drupal_write_record('active_translation', $translation);
+    }
     $context['sandbox']['progress']++;
     $context['sandbox']['current_translation'] = $row->tnid;
   }
 
-  // Multistep processing : report progress.
-  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
+  // Multistep processing: report progress.
+  if ($context['sandbox']['progress'] < $context['sandbox']['max']) {
     $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
   }
 }
 
 function _active_translation_batch_finished($success, $results, $operations) {
   if ($success) {
+    watchdog('active_translation', 'Sucessfully rebuilt the active translation table.');
     drupal_set_message(t('The active translation table has rebuilt.'));
   }
   else {
+    watchdog('active_translation', 'There was an error that prevented the active translation table from being properly rebuilt.', array(), WATCHDOG_ERROR);
     drupal_set_message(t('The active translation table has not been properly rebuilt.'), 'error');
   }
   cache_clear_all();
Index: active_translation.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/active_translation/active_translation.install,v
retrieving revision 1.6
diff -u -p -r1.6 active_translation.install
--- active_translation.install	15 Jun 2008 19:49:30 -0000	1.6
+++ active_translation.install	19 Jun 2008 08:47:24 -0000
@@ -5,8 +5,7 @@
  * Implementation of hook_install().
  */
 function active_translation_install() {
-  // We don't do any schema installation here, it happens in
-  // _active_translation_batch_operation().
+  // The schema installation happens in active_translation_enable().
 }
 
 /**
@@ -20,6 +19,8 @@ function active_translation_uninstall() 
  * Implementation of hook_enable().
  */
 function active_translation_enable() {
+  drupal_install_schema('active_translation');
+
   require_once drupal_get_path('module', 'active_translation') .'/active_translation.batch.inc';
   batch_set(active_translation_build_batch_all());
 }
