diff --git a/includes/commerce.controller.inc b/includes/commerce.controller.inc index eb6277c..fb9c78e 100644 --- a/includes/commerce.controller.inc +++ b/includes/commerce.controller.inc @@ -13,7 +13,7 @@ class DrupalCommerceEntityController extends DrupalDefaultEntityController imple * Stores our transaction object, necessary for pessimistic locking to work. */ protected $controllerTransaction = NULL; - + /** * Stores ids of locked entities, necessary for knowing when to * release the lock by committing the transaction. @@ -44,18 +44,23 @@ class DrupalCommerceEntityController extends DrupalDefaultEntityController imple public function resetCache(array $ids = NULL) { parent::resetCache($ids); - - // Maintain the list of locked entities, so that the releaeLock() method + + // Maintain the list of locked entities, so that the releaseLock() method // can know when it's time to commit the transaction. if (!empty($this->lockedEntities)) { - foreach ($ids as $id) { - unset($this->lockedEntities[$id]); + if (isset($ids)) { + foreach ($ids as $id) { + unset($this->lockedEntities[$id]); + } + } + else { + $this->lockedEntities = array(); } } // Try to release the lock, if possible. $this->releaseLock(); } - + /** * Checks the list of tracked locked entities, and if it's empty, commits * the transaction in order to remove the acquired locks. diff --git a/modules/order/tests/commerce_order_ui.test b/modules/order/tests/commerce_order_ui.test index 5011ddb..7ae2923 100644 --- a/modules/order/tests/commerce_order_ui.test +++ b/modules/order/tests/commerce_order_ui.test @@ -147,13 +147,13 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, array(), t('Save order', array(), array('context' => 'a drupal commerce order'))); // Reload the order directly from db. - $order = reset(commerce_order_load_multiple(array($this->order->order_id), array(), TRUE)); + $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); // Reset the cache as we don't want to keep the lock. entity_get_controller('commerce_order')->resetCache(); // Check if the product has been added to the order. - foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $delta => $line_item_wrapper) { + foreach (entity_metadata_wrapper('commerce_order', reset($order))->commerce_line_items as $delta => $line_item_wrapper) { if ($line_item_wrapper->type->value() == 'product') { $product = $line_item_wrapper->commerce_product->value(); $products[$product->product_id]= $product; diff --git a/modules/payment/tests/commerce_payment_ui.test b/modules/payment/tests/commerce_payment_ui.test index 80f9d9b..80ce475 100644 --- a/modules/payment/tests/commerce_payment_ui.test +++ b/modules/payment/tests/commerce_payment_ui.test @@ -165,12 +165,12 @@ class CommercePaymentUITest extends CommerceBaseTestCase { $this->drupalPost(NULL, $post_data, t('Save')); // Reload the order. - $order = reset(commerce_order_load_multiple(array($this->order->order_id), array(), TRUE)); + $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); // Reset the cache as we don't want to keep the lock. entity_get_controller('commerce_order')->resetCache(); // Check order balance, it should be half of total now. - $new_balance = commerce_payment_order_balance($order); + $new_balance = commerce_payment_order_balance(reset($order)); $this->assertEqual($new_balance['amount'], $balance['amount'] - $payment_amount, t('After half payment order balance is correct')); $this->assertRaw('