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	17 Jun 2008 19:37:20 -0000
@@ -19,7 +19,7 @@ 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));
@@ -41,31 +41,46 @@ 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.
+    $sql = 'INSERT INTO {active_translation} (atid, '. implode(', ', $fields) .') SELECT DISTINCT(nid), '. implode(', ', $values) .' FROM {node} WHERE tnid = 0 ORDER BY tnid';
+#    watchdog('active_translation', 'Running query: @sql', array('@sql' => $sql), WATCHDOG_DEBUG);
+    db_query($sql);
+
+    watchdog('active_translation', 'Created records for untranslated and language neutral nodes.');
   }
 
   // Process the next set of translations.
   $limit = 20;
   $result = db_query_range("SELECT DISTINCT tnid FROM {node} WHERE tnid > %d ORDER BY tnid ASC", $context['sandbox']['current_translation'], 0, $limit);
+  watchdog('active_translation', 'Processing @limit translations of @max. starting at tnid @tnid', array('@limit' => $limit, '@max' => $context['sandbox']['max'], '@tnid' => $context['sandbox']['current_translation']), WATCHDOG_DEBUG);
   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']) {
+    watchdog('active_translation', 'Still have more nodes to process...', array(), WATCHDOG_DEBUG);
     $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	17 Jun 2008 19:37:20 -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());
 }
