Index: mollom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.install,v
retrieving revision 1.24
diff -u -p -r1.24 mollom.install
--- mollom.install	10 Aug 2010 19:33:51 -0000	1.24
+++ mollom.install	12 Sep 2010 19:02:50 -0000
@@ -536,3 +536,41 @@ function mollom_update_7005() {
     'not null' => FALSE,
   ));
 }
+
+/**
+ * Update for changed comment form IDs.
+ *
+ * Since we are not able to know, on which nodes the comment form is actually
+ * enabled, we can only protect all possible comment forms.
+ */
+function mollom_update_7006() {
+  // Skip this update in case comment_form is not protected.
+  $mollom_form = db_query("SELECT * FROM {mollom_form} WHERE form_id = :form_id", array(':form_id' => 'comment_form'))->fetchAssoc();
+  if (!$mollom_form) {
+    return;
+  }
+
+  // Retrieve available node types.
+  // @todo Remove after http://drupal.org/node/898520 landed.
+  if (function_exists('_update_7000_node_get_types')) {
+    $types = _update_7000_node_get_types();
+  }
+  else {
+    $types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ);
+  }
+
+  // Duplicate comment_form row into comment_node_TYPE_form rows.
+  // Using db_merge() instead of db_insert() to account for manually performed
+  // updates or re-configuration.
+  unset($mollom_form['form_id']);
+  $query = db_merge('mollom_form')
+    ->fields($mollom_form);
+  foreach ($types as $type) {
+    $update = clone $query;
+    $update
+      ->key(array('form_id' => "comment_node_{$type->type}_form"))
+      ->execute();
+  }
+
+  // @todo Do we also have to update Mollom data in {mollom}?
+}
