? .cvsignore
? privatemsg_fix_update_functions.patch
Index: privatemsg.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.install,v
retrieving revision 1.19
diff -u -p -r1.19 privatemsg.install
--- privatemsg.install	5 Aug 2010 09:29:21 -0000	1.19
+++ privatemsg.install	27 Sep 2010 09:49:31 -0000
@@ -514,9 +514,14 @@ function privatemsg_update_6006() {
 /**
  * Add {pm_disable} table.
  */
-function privatemsg_update_6007() {
+function privatemsg_update_6200() {
   $ret = array();
 
+  // Make sure to not run this update twice.
+  if (db_table_exists('pm_disable')) {
+    return $ret;
+  }
+
   $schema['pm_disable'] = array(
     'description'       => '{pm_disable} holds the list of users that have disabled private messaging',
     'fields' => array(
@@ -540,8 +545,13 @@ function privatemsg_update_6007() {
 /**
  * Change schema to allow other recipients than single users.
  */
-function privatemsg_update_6008() {
+function privatemsg_update_6201() {
   $ret = array();
+
+  // Make sure to not run this update twice.
+  if (db_column_exists('pm_index', 'recipient')) {
+    return $ret;
+  }
   db_drop_index($ret, 'pm_index', 'uid');
   db_drop_index($ret, 'pm_index', 'is_new');
   db_change_field($ret, 'pm_index', 'uid', 'recipient', array(
@@ -566,7 +576,7 @@ function privatemsg_update_6008() {
 /**
  * Remove duplicate entries in {pm_index}.
  */
-function privatemsg_update_6009(&$sandbox) {
+function privatemsg_update_6202(&$sandbox) {
   // First run, initialize sandbox and check if we are ready to run.
   if (!isset($sandbox['current_thread_id'])) {
     // If privatemsg_filter is enabled, check if the updates that add the Inbox
@@ -618,8 +628,12 @@ function privatemsg_update_6009(&$sandbo
 /**
  * Add primary key to {pm_index}.
  */
-function privatemsg_update_6010() {
+function privatemsg_update_6203() {
   $ret = array();
   db_add_primary_key($ret, 'pm_index', array('mid', 'recipient', 'type'));
+  // Ignore error that happens when this update runs twice.
+  if (!$ret[0]['success']) {
+    unset($ret[0]);
+  }
   return $ret;
 }
Index: privatemsg_filter/privatemsg_filter.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.install,v
retrieving revision 1.6
diff -u -p -r1.6 privatemsg_filter.install
--- privatemsg_filter/privatemsg_filter.install	6 Jun 2010 15:13:47 -0000	1.6
+++ privatemsg_filter/privatemsg_filter.install	27 Sep 2010 09:49:31 -0000
@@ -127,7 +127,7 @@ function privatemsg_filter_update_6002()
 /**
  * Add hidden flag and create inbox tag.
  */
-function privatemsg_filter_update_6003() {
+function privatemsg_filter_update_6200() {
   $ret = array();
   if (!db_column_exists('pm_tags', 'hidden')) {
     db_add_column($ret, 'pm_tags', 'hidden', 'int', array(
@@ -149,10 +149,16 @@ function privatemsg_filter_update_6003()
 /**
  * Add inbox tag to existing inbox messages.
  */
-function privatemsg_filter_update_6004(&$sandbox) {
+function privatemsg_filter_update_6201(&$sandbox) {
 
   // First run, initialize sandbox.
   if (!isset($sandbox['current_thread_id'])) {
+    // If the sandbox is not initialized, check if there are any threads tagged
+    // with the inbox tag. If yes, the update did already run.
+    if (db_result(db_query_range('SELECT 1 FROM {pm_tags_index} WHERE tag_id = %d', variable_get('privatemsg_filter_inbox_tag', 0), 0, 1))) {
+      return array();
+    }
+
     $sandbox['current_thread_id'] = 0;
     // Assume that the thread ids are distributed more or less equally over the
     // whole data set. This allows us to calculate the approximate progress.
