Index: themekey_ui.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/themekey/themekey_ui.install,v
retrieving revision 1.3
diff -u -r1.3 themekey_ui.install
--- themekey_ui.install	13 Nov 2009 17:58:39 -0000	1.3
+++ themekey_ui.install	20 Nov 2009 19:50:42 -0000
@@ -58,9 +58,8 @@
     $sql = "SELECT id, value, theme, nid, vid FROM {themekey_properties} JOIN {node_revisions} ON (value = nid) WHERE property = 'node:nid' AND conditions = '%s'";
     if ($result = db_query($sql, 'a:0:{}')) {
       $insert_sql = "INSERT INTO {themekey_ui_node_theme} (nid, vid, theme) VALUES (%d, %d, '%s')";
-      $return['INSERT']['query'] = check_plain($insert_sql);
       $delete_sql = "DELETE FROM {themekey_properties} WHERE id = %d";
-      $return['DELETE']['query'] = check_plain($delete_sql);
+
       while ($row = db_fetch_array($result)) {
         if ($return['INSERT']['success'] = db_query($insert_sql, $row['nid'], $row['vid'], $row['theme'])) {
           if (!($return['DELETE']['success'] = db_query($delete_sql, $row['id']))) {
@@ -72,6 +71,14 @@
           break;
         }
       }
+
+      if (isset($return['INSERT'])) {
+        $return['INSERT']['query'] = check_plain($insert_sql);
+      }
+
+      if (isset($return['DELETE'])) {
+        $return['DELETE']['query'] = check_plain($delete_sql);
+      }
     }
     else {
       $return['SELECT'] = array('success' => FALSE, 'query' => check_plain($sql));
