Index: uc_upsell_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_upsell/Attic/uc_upsell_admin.inc,v
retrieving revision 1.1.2.18
diff -u -p -r1.1.2.18 uc_upsell_admin.inc
--- uc_upsell_admin.inc	31 Jul 2009 20:18:27 -0000	1.1.2.18
+++ uc_upsell_admin.inc	6 Aug 2009 02:24:25 -0000
@@ -109,23 +109,22 @@ function uc_upsell_relateds_add($node) {
       $products[] = $product;
 
       $related = _uc_upsell_get_related($product);
+      //drupal_set_message('looking for related to --> '.$product. 'and found '.print_r($related, true));
 
       // Only perform reciprocal actions if we're configured to do so.
       if ($config['global']['reciprocal_behavior'] != 'none') {
 
         //dsm('Updating reciprocals');
-        if (count($related) == 0) {
+        if (!$related) {
           // Add a new row for this product
+          //drupal_set_message('inserting 1');
           uc_upsell_insert_nids($product, $ary);
-            //dsm('1 sent to '.$product.''.print_r($ary, true));
+          //dsm('1 sent to '.$product.''.print_r($ary, true));
         }
         else {
-          if (is_array($ary)) {
-            if (is_array($related)) {
-              //$related = unserialize($related);
-              $ary = array_merge($ary, $related);
-              $ary = array_unique($ary);
-            }
+          if (is_array($ary)) {                  
+            $ary = array_merge($ary, $related);
+            $ary = array_unique($ary);          
           }
           // Update this product's related nodes (a row already exists)
           uc_upsell_update_nids($product, $ary);
@@ -138,7 +137,7 @@ function uc_upsell_relateds_add($node) {
             //dsm('=======> updating '.$value);
             $currentnids = _uc_upsell_get_related($nid);
             
-            if (is_array($currentnids)) {
+            if ($currentnids) {
               $merge = array_unique(array_merge($currentnids, $products));
               $merge = array_diff($merge, (array)$nid); // Get rid of the current nid
               //dsm('used value '.print_r((array)$value, true));
@@ -154,7 +153,7 @@ function uc_upsell_relateds_add($node) {
         // Get the list of related products for the current product
         $currentnids = _uc_upsell_get_related($node->nid);
 
-        if (count($currentnids) > 0) {       
+        if ($currentnids) {       
           // Delete current product from the related products list for any products that are being removed
           foreach ($currentnids as $currentnid) {
             if (!in_array($currentnid, $products)) {
@@ -201,8 +200,10 @@ function _uc_upsell_get_related($nid) {
     return unserialize($currentnids);
   }
   else {
-    return array();
+    return FALSE;
   }
+  //drupal_set_message('get_related returned '.print_r($return, true));
+  //return $return;
 }
 
 /**
@@ -217,7 +218,7 @@ function _uc_upsell_remove_related($nid,
 
   $currentnids = _uc_upsell_get_related($nid);
 
-  if (is_array($currentnids)) {
+  if ($currentnids) {
     // Get the array minus the nid to be removed and update the db
     $updatenids = array_diff((array)$currentnids, (array)$removed);
     db_query("UPDATE {uc_upsell_products} SET related_products = '%s' WHERE nid = %d", serialize($updatenids), $nid);
@@ -591,6 +592,4 @@ function uc_upsell_insert_nids($nid, $ni
  */
 function uc_upsell_update_nids($nid, $nids) {
   db_query("UPDATE {uc_upsell_products} SET `related_products` = '%s' WHERE `nid` = %d", serialize($nids), $nid);
-}
-
-
+}
\ No newline at end of file
