=== modified file 'uc_attribute/uc_attribute.admin.inc'
--- uc_attribute/uc_attribute.admin.inc	2009-09-23 18:21:45 +0000
+++ uc_attribute/uc_attribute.admin.inc	2009-10-07 14:04:40 +0000
@@ -933,7 +933,7 @@
  *     #options - Array of option names
  * @return Themed set of attribute options.
  */
-function theme_uc_product_attributes(&$element) {
+function theme_uc_product_attributes($element) {
   $option_rows = array();
 
   foreach (element_children($element) as $key) {

=== modified file 'uc_cart/uc_cart.module'
--- uc_cart/uc_cart.module	2009-09-23 15:38:25 +0000
+++ uc_cart/uc_cart.module	2009-10-07 14:03:41 +0000
@@ -1354,9 +1354,12 @@
       $item->model = $product->model;
 
       // Invoke hook_cart_item() with $op = 'load' in enabled modules.
-      foreach (module_implements('cart_item') as $module) {
+      foreach (module_list() as $module) {
         $func = $module .'_cart_item';
-        $func('load', $item);
+        if (function_exists($func)) {
+          // $item must be passed by reference.
+          $func('load', $item);
+        }
       }
 
       $items[$cid][] = $item;
@@ -1420,10 +1423,14 @@
   $item->model = $product->model;
 
   // Invoke hook_cart_item() with $op = 'load' in enabled modules.
-  foreach (module_implements('cart_item') as $module) {
+  foreach (module_list() as $module) {
     $func = $module .'_cart_item';
-    $func('load', $item);
+    if (function_exists($func)) {
+      // $item must be passed by reference.
+      $func('load', $item);
+    }
   }
+
   return $item;
 }
 
@@ -1547,9 +1554,12 @@
   // Invoke hook_cart_item() with $op = 'remove' in enabled modules.
   $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 = '%s' AND c.nid = %d", $cart_id, $nid);
   if ($item = db_fetch_object($result)) {
-    foreach (module_implements('cart_item') as $module) {
+    foreach (module_list() as $module) {
       $func = $module .'_cart_item';
-      $func('remove', $item);
+      if (function_exists($func)) {
+        // $item must be passed by reference.
+        $func('remove', $item);
+      }
     }
   }
 
@@ -1665,7 +1675,13 @@
   }
 
   // See if any other modules have a say in the matter...
-  $result = module_invoke_all('cart_item', 'can_ship', $product);
+  foreach (module_list() as $module) {
+    $func = $module .'_cart_item';
+    if (function_exists($func)) {
+      // $product must be passed by reference.
+      $result[] = $func('can_ship', $product);
+    }
+  }
 
   // Return TRUE by default.
   if (empty($result) || in_array(TRUE, $result)) {

=== modified file 'uc_cart/uc_cart.pages.inc'
--- uc_cart/uc_cart.pages.inc	2009-09-23 20:26:15 +0000
+++ uc_cart/uc_cart.pages.inc	2009-10-07 14:03:17 +0000
@@ -492,21 +492,25 @@
   $error = FALSE;
 
   // Invoke it on a per-module basis instead of all at once.
-  foreach (module_implements('order') as $module) {
-    $result = module_invoke($module, 'order', 'submit', $order, NULL);
-
-    $msg_type = 'status';
-    if ($result[0]['pass'] === FALSE) {
-      $error = TRUE;
-      $msg_type = 'error';
-    }
-    if (!empty($result[0]['message'])) {
-      drupal_set_message($result[0]['message'], $msg_type);
-    }
-
-    // Stop invoking the hooks if there was an error.
-    if ($error) {
-      break;
+  foreach (module_list() as $module) {
+    $function = $module .'_order';
+    if (function_exists($function)) {
+      // $order must be passed by reference.
+      $result = $function('submit', $order, NULL);
+
+      $msg_type = 'status';
+      if ($result[0]['pass'] === FALSE) {
+        $error = TRUE;
+        $msg_type = 'error';
+      }
+      if (!empty($result[0]['message'])) {
+        drupal_set_message($result[0]['message'], $msg_type);
+      }
+
+      // Stop invoking the hooks if there was an error.
+      if ($error) {
+        break;
+      }
     }
   }
 

=== modified file 'uc_order/uc_order.admin.inc'
--- uc_order/uc_order.admin.inc	2009-09-23 18:23:18 +0000
+++ uc_order/uc_order.admin.inc	2009-10-07 14:03:41 +0000
@@ -1314,7 +1314,13 @@
       $product->price = $product->sell_price;
       $product->data = module_invoke_all('add_to_cart_data', $form_state['values']);
 
-      module_invoke_all('cart_item', 'load', $product);
+      foreach (module_list() as $module) {
+        $function = $module .'_cart_item';
+        if (function_exists($function)) {
+          // $product must be passed by reference.
+          $function('load', $product);
+        }
+      }
 
       $price_info = array(
         'price' => $product->price,

=== modified file 'uc_order/uc_order.module'
--- uc_order/uc_order.module	2009-09-22 14:36:22 +0000
+++ uc_order/uc_order.module	2009-10-07 14:03:41 +0000
@@ -1027,7 +1027,7 @@
            $uid, $order->order_status, $email, time(), time());
   $order->order_id = db_last_insert_id('uc_orders', 'order_id');
 
-  module_invoke_all('order', 'new', $order, NULL);
+  uc_order_module_invoke('new', $order, NULL);
 
   return $order;
 }
@@ -1066,12 +1066,7 @@
     }
   }
 
-  // Invoke hook_order() in enabled modules.
-  foreach (module_implements('order') as $module) {
-    $func = $module .'_order';
-    $null = NULL;
-    $func('save', $order, $null);
-  }
+  uc_order_module_invoke('save', $order, NULL);
 }
 
 /**
@@ -1129,12 +1124,7 @@
     $order->products[] = $product;
   }
 
-  // Invoke hook_order() in enabled modules.
-  foreach (module_implements('order') as $module) {
-    $func = $module .'_order';
-    $null = NULL;
-    $func('load', $order, $null);
-  }
+  uc_order_module_invoke('load', $order, NULL);
 
   // Load line items... has to be last after everything has been loaded.
   $order->line_items = uc_order_load_line_items($order, TRUE);
@@ -1170,12 +1160,7 @@
 
   // Perform the operations if we're deleting a valid order.
   if ($order !== FALSE) {
-    // Invoke hook_order() in enabled modules.
-    foreach (module_implements('order') as $module) {
-      $func = $module .'_order';
-      $null = NULL;
-      $func('delete', $order, $null, NULL);
-    }
+    uc_order_module_invoke('delete', $order, NULL);
 
     // Delete data from the appropriate Ubercart order tables.
     db_query("DELETE FROM {uc_orders} WHERE order_id = %d", $order_id);
@@ -1311,16 +1296,21 @@
   // Attempt the update if the order exists.
   if ($order !== FALSE) {
     // Return false if any module says the update is not good to go.
-    $return = module_invoke_all('order', 'can_update', $order, $status);
-    for ($i = 0; $i < count($return); $i++) {
-      if ($return[$i] === FALSE) {
-        return FALSE;
+    foreach (module_list() as $module) {
+      $function = $module .'_order';
+      // $order must be passed by reference.
+      if (function_exists($function) && ($return = $function('can_update', $order, $status))){
+        for ($i = 0; $i < count($return); $i++) {
+          if ($return[$i] === FALSE) {
+            return FALSE;
+          }
+        }
       }
     }
 
     // Otherwise perform the update and log the changes.
     db_query("UPDATE {uc_orders} SET order_status = '%s', modified = %d WHERE order_id = %d", $status, time(), $order_id);
-    module_invoke_all('order', 'update', $order, $status);
+    uc_order_module_invoke('update', $order, $status);
 
     $change = array(t('Order status') => array('old' => uc_order_status_data($order->order_status, 'title'), 'new' => uc_order_status_data($status, 'title')));
     uc_order_log_changes($order->order_id, $change);
@@ -1396,6 +1386,21 @@
 }
 
 /**
+ * Invokes hook_order() in every module.
+ *
+ * We cannot use module_invoke() for this, because the arguments need to
+ * be passed by reference.
+ */
+function uc_order_module_invoke($op, &$order, $edit) {
+  foreach (module_list() as $module) {
+    $function = $module .'_order';
+    if (function_exists($function)) {
+      $function($op, $order, $edit);
+    }
+  }
+}
+
+/**
  * Return TRUE if an order exists.
  */
 function uc_order_exists($order_id) {
@@ -1418,6 +1423,10 @@
 function uc_order_get_total($order, $products_only = FALSE) {
   $total = 0;
 
+  if ($order === FALSE) {
+    return $total;
+  }
+
   if (is_array($order->products)) {
     $context = array(
       'revision' => 'altered',
@@ -1444,9 +1453,12 @@
 
   $total += uc_line_items_calculate($order);
 
-  $result = module_invoke_all('order', 'total', $order, NULL);
-  foreach ($result as $key => $value) {
-    $total += $value;
+  foreach (module_list() as $module) {
+    $function = $module .'_order';
+    // $order must be passed by reference.
+    if (function_exists($function) && ($value = $function('total', $order, NULL))) {
+      $total += $value;
+    }
   }
 
   return $total;
@@ -1483,7 +1495,13 @@
     }
 
     // See if any other modules have a say in the matter...
-    $result = module_invoke_all('cart_item', 'can_ship', $product);
+    foreach (module_list() as $module) {
+      $function = $module .'_cart_item';
+      if (function_exists($function)) {
+        // $product must be passed by reference.
+        $result[] = $function('can_ship', $product);
+      }
+    }
 
     // Return TRUE by default.
     if (empty($result) || in_array(TRUE, $result)) {
@@ -1817,12 +1835,15 @@
       }
       else {
         // See if any modules have a say in this order's eligibility for deletion
-        $return = module_invoke_all('order', 'can_delete', $order, NULL);
-        foreach ((array)$return as $response) {
-          // Break out early if possible.
-          if ($response === FALSE) {
-            $can_delete = FALSE;
-            break;
+        foreach (module_list() as $module) {
+          $function = $module .'_order';
+          // $order must be passed by reference.
+          if (function_exists($function) && ($response = $function('can_delete', $order, NULL))) {
+            // Break out early if possible.
+            if ($response === FALSE) {
+              $can_delete = FALSE;
+              break;
+            }
           }
         }
       }

=== modified file 'uc_product/uc_product.module'
--- uc_product/uc_product.module	2009-09-23 18:21:45 +0000
+++ uc_product/uc_product.module	2009-10-07 14:04:40 +0000
@@ -1005,7 +1005,7 @@
  * Reset a content type's default image field setting when that field instance
  * is removed.
  */
-function uc_product_content_fieldapi($op, &$field) {
+function uc_product_content_fieldapi($op, $field) {
   switch ($op) {
     case 'delete instance':
       if ($field->field_name == variable_get('uc_image_'. $field->type_name, NULL)) {

=== modified file 'uc_product_kit/uc_product_kit.module'
--- uc_product_kit/uc_product_kit.module	2009-09-23 15:38:25 +0000
+++ uc_product_kit/uc_product_kit.module	2009-10-07 14:03:41 +0000
@@ -950,7 +950,13 @@
     $kit_product->data['kit_id'] = $product->nid;
 
     // Run the product through the alter mill.
-    module_invoke_all('cart_item', 'load', $kit_product);
+    foreach (module_list() as $module) {
+      $function = $module .'_cart_item';
+      if (function_exists($function)) {
+        // $product must be passed by reference.
+        $function('load', $kit_product);
+      }
+    }
 
     $price_info = array(
       'price' => $kit_product->price,

