I attempted to update a product kit by adding a new item, and received an error message for attempting to access a non-object, and a PDO exception with null values for quantity and discount. The offending code is in uc_product_kit.module (beginning line 269), which attempts to define a value for discount, then quantity from cascading if...else statements. The final statement in each case fails to test if the value is set, and causes the error. I corrected the error by putting a test in for the last value, and then defining a default in code:

    elseif (isset($node->products[$nid]->discount))  {
      $discount = $node->products[$nid]->discount;
    } else {
      $discount = 0;
    }

    if (isset($node->items)) {
      if (!isset($node->items[$nid]['qty']) || $node->items[$nid]['qty'] === '') {
        $node->items[$nid]['qty'] = 1;
      }

      $product->qty = $node->items[$nid]['qty'];
    }
    elseif (isset($node->products[$nid]->qty))  {
      $product->qty = $node->products[$nid]->qty;
    } else {
      $product->qty = 1;
    }

I have attached a patch for your review.

CommentFileSizeAuthor
uc_product_kit.patch1.33 KBTriskelion

Comments

tr’s picture

Status: Patch (to be ported) » Needs review
muka’s picture

+1 works for me, thank you

longwave’s picture