Noted when fixing #1305634: Deduplicate uc_cart_get_item() and uc_cart_get_contents()

    $result = db_query("SELECT c.*, n.title, n.vid FROM {node} n INNER JOIN {uc_cart_products} c ON n.nid = c.nid WHERE c.cart_id = :id ORDER BY c.cart_item_id ASC", array(':id' => $cid));

    foreach ($result as $item) {
      $product = node_load($item->nid);

We don't need the join at all; we can just get the title and vid from the node_load() result.

Comments

longwave’s picture

Status: Active » Needs review
StatusFileSize
new1.41 KB
longwave’s picture

Version: 7.x-3.x-dev » 6.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed to 7.x.

longwave’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.37 KB
longwave’s picture

Status: Needs review » Fixed

Committed.

longwave’s picture

Status: Fixed » Needs work

Oops, this breaks the case where nodes are deleted but remain in the cart. Perhaps we should have a test for that!

longwave’s picture

Status: Needs work » Fixed

Fixed in both branches, and added a test to ensure deleted nodes don't show up in the cart.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.