# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
--- taxonomy_vocab_relate.module
+++ taxonomy_vocab_relate.module.new
@@ -77,7 +77,30 @@
     foreach ($form_state['values']['relations_'. $rvid] as $related_id) {
       if ($related_id != 0) {
         db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $form_state['values']['tid'], $related_id);
+		db_query('DELETE FROM {term_relation_cache} WHERE tid1=%d AND tid2=%d', $form_state['values']['tid'], $related_id);
+		db_query('INSERT INTO {term_relation_cache} (tid1, tid2) VALUES (%d, %d)', $form_state['values']['tid'], $related_id);
       }
     }
   }
 }
+
+function taxonomy_vocab_relate_taxonomy($op, $subject, $values) {
+	drupal_set_message($op);
+	drupal_set_message($subject);
+	if($subject != 'term'){
+		return NULL;
+	}
+	
+	$term = (object)$values;
+	switch($op){
+		case 'update':
+			$result = db_query('SELECT tid1 FROM {term_relation_cache} WHERE tid2= %d', $term->tid);
+			while($row = db_fetch_array($result)){
+				db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $row['tid1'], $term->tid);
+			}
+		break;
+		case 'delete':
+			db_query('DELETE FROM {term_relation_cache} WHERE tid2=%d', $term->tid);
+		break;		
+	}
+}
\ No newline at end of file
