Posted by kwikone on January 16, 2008 at 4:19pm
Jump to:
| Project: | Wishlist Module |
| Version: | 6.x-2.1-beta |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
wishlist.module gets PHP notice Undefined variable $rows at line 729. This occurs since $rows is not declared until within an if. (lines 707 - 731 below)
if(!is_null($node->nid) && $node->nid > 0) {
// Retrieve all of the records showing what the currently logged in user purchaed on this item.
$result = db_query(db_rewrite_sql("SELECT p.wishlist_purch_wid, p.wishlist_purch_buyer_uid, p.wishlist_purch_quantity FROM {wishlist_purchased} p WHERE p.wishlist_purch_buyer_uid=%d AND p.wishlist_purch_nid=%d", "p", "wishlist_purch_buyer_nid"),$user->uid, $node->nid);
$header = array(
array('data' => t("Quantity<br>You<br>Purchased")),
array('data' => t("Action"))
);
while($wishlist_purch = db_fetch_object($result)) {
if ($wishlist_purch->wishlist_purch_quantity > 1) {
$action_str = t("Return these items");
} else {
$action_str = t("Return this item");
}
$rows[] = array(
array("data" => $wishlist_purch->wishlist_purch_quantity),
array("data" => l($action_str, "wishlist/item/$node->nid/return/$wishlist_purch->wishlist_purch_wid"))
);
}
if ($rows) {
$output .= "<div class='wishlist_purchased'>".theme('table', $header, $rows)."</div>";
}
}This can be resolved by...
if(!is_null($node->nid) && $node->nid > 0) {
// Retrieve all of the records showing what the currently logged in user purchaed on this item.
$result = db_query(db_rewrite_sql("SELECT p.wishlist_purch_wid, p.wishlist_purch_buyer_uid, p.wishlist_purch_quantity FROM {wishlist_purchased} p WHERE p.wishlist_purch_buyer_uid=%d AND p.wishlist_purch_nid=%d", "p", "wishlist_purch_buyer_nid"),$user->uid, $node->nid);
$header = array(
array('data' => t("Quantity<br>You<br>Purchased")),
array('data' => t("Action"))
);
$rows = array(); // if there were no records, we don't want an undefined variable notification
while($wishlist_purch = db_fetch_object($result)) {
if ($wishlist_purch->wishlist_purch_quantity > 1) {
$action_str = t("Return these items");
} else {
$action_str = t("Return this item");
}
$rows[] = array(
array("data" => $wishlist_purch->wishlist_purch_quantity),
array("data" => l($action_str, "wishlist/item/$node->nid/return/$wishlist_purch->wishlist_purch_wid"))
);
}
if ($rows) {
$output .= "<div class='wishlist_purchased'>".theme('table', $header, $rows)."</div>";
}
}
Comments
#1
$rows = array(); // if there were no records, we don't want an undefined variable notification
added in as suggested.
#2
Automatically closed -- issue fixed for two weeks with no activity.