? oops.diff
? uuid
? uuid-895622-uuid-b2-v3-D6.patch
? uuid-dupes.diff
? uuid-dupes2.diff
? uuid-dupes3.diff
? uuid-dupes4.diff
Index: uuid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.module,v
retrieving revision 1.1.2.17
diff -u -p -r1.1.2.17 uuid.module
--- uuid.module	16 Nov 2010 02:57:59 -0000	1.1.2.17
+++ uuid.module	18 Jan 2011 01:57:00 -0000
@@ -24,6 +24,17 @@ function uuid_menu() {
 
   return $items;
 }
+/**
+ * Load the uuid information for a node.
+ */
+function uuid_node_load($node) {
+  if ($arr = db_fetch_array(db_query('SELECT un.uuid AS uuid, unr.uuid AS revision_uuid FROM uuid_node un LEFT JOIN uuid_node_revisions unr ON unr.vid=%d WHERE un.nid=%d', $node->vid, $node->nid))) {
+    return $arr;
+  }
+  else {
+   return array('uuid'=>FALSE, 'revision_uuid'=>FALSE);
+  }  
+}
 
 /**
  * Implementation of hook_nodeapi().
@@ -33,12 +44,7 @@ function uuid_nodeapi(&$node, $op, $teas
 
   switch ($op) {
     case 'load':
-      $revision_uuid = db_result(db_query('SELECT uuid FROM {uuid_node_revisions} WHERE vid = %d', $node->vid));
-      return array(
-        'uuid' => db_result(db_query('SELECT uuid FROM {uuid_node} WHERE nid = %d', $node->nid)),
-        'revision_uuid' => $revision_uuid,
-        'loaded_revision_uuid' => $revision_uuid,
-      );
+      return uuid_node_load($node);
     case 'insert':
       // Handle the case where automatic UUID generation is turned OFF but a
       // node is created, node_save(), intentionally with the $node->uuid
@@ -63,14 +69,18 @@ function uuid_nodeapi(&$node, $op, $teas
       }
       break;
     case 'update':
-      if (isset($node->revision)) {
-        if (isset($node->revision_uuid) && uuid_is_valid($node->revision_uuid) && $node->revision_uuid != $node->loaded_revision_uuid) {
-          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
-        }
-        else {
-          $node->revision_uuid = uuid_uuid();
-          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
-        }
+      // Are we creating a new revision?
+      $uuid_information = uuid_node_load($node);
+      foreach ($uuid_information as $key => $value) {
+        $node->$key = $value;
+      }
+      // Create a new uuid for this revision if the node already has a uuid
+      // or if the content type is configured to have uuids
+      // automatically assigned.
+      if (!empty($node->revision) && (in_array($node->type, $automatic_types) || !empty($node->uuid))) {
+        // Assign a new uuid to this revision.
+        $node->revision_uuid = uuid_uuid();
+        db_query("INSERT INTO {uuid_node_revisions} (vid, uuid, nid) VALUES (%d, '%s', %d)", $node->vid, $node->revision_uuid, $node->nid);
       }
       break;
     case 'delete':
