Index: uuid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.module,v
retrieving revision 1.1.2.16
diff -u -p -r1.1.2.16 uuid.module
--- uuid.module	9 Oct 2010 01:43:23 -0000	1.1.2.16
+++ uuid.module	14 Oct 2010 01:53:19 -0000
@@ -33,12 +33,12 @@ 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,
-      );
+      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, 'loaded_revision_uuid' => FALSE);
+      }
     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,13 +63,13 @@ 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);
+      if (isset($node->revision) && in_array($node->type, $automatic_types)) {
+        $exists = db_result(db_query('SELECT 1 FROM {uuid_node_revisions} WHERE vid = %d', $node->vid));
+        if (!$exists) {
+          if (!isset($node->revision_uuid) || !uuid_is_valid($node->revision_uuid)) {
+            $node->revision_uuid = uuid_uuid();
+          }
+          db_query("INSERT INTO {uuid_node_revisions} (vid, uuid) VALUES (%d, '%s')", $node->vid, $node->revision_uuid);
         }
       }
       break;
@@ -111,7 +111,7 @@ function node_get_by_uuid($uuid) {
 /**
  * Returns the node associated with a revision UUID.
  *
- * @param $revision_uuid
+ * @param string $revision_uuid
  *   The uuid to use for the node lookup.
  *
  * @return
