Our site has a commerce shipping 1 and the flat rate module enabled with a few flat rate options. I have been trying to upgrade to shipping 2.0 (like documented in the release notes), but the database update fails:

# drush updatedb
The following updates are pending:

commerce_shipping module : 
  7100 -   Upgrade from Commerce Shipping 1.x by renaming the commerce_shipping_method  field on the shipping line item type to commerce_shipping_service and  converting price components on shipping line items to the generic Shipping  price component type. Before proceeding, ensure that any shipping method  modules designed to work with Commerce Shipping 1.x have been disabled but  not uninstalled. They may be uninstalled after the update is complete. 

Do you wish to run all pending updates? (y/n): y
WD commerce_order: EntityMalformedException: Missing bundle property on entity of [error]
type commerce_order. in entity_extract_ids() (line 7562 of
/data/www/7dev/includes/common.inc).
Missing bundle property on entity of type commerce_order.                         [error]
Performed update: commerce_shipping_update_7100                                   [ok]
Finished performing updates. 

(same problem if I run update.php in a browser)

Any idea what may cause this? I suppose it can be hard to find out which entity is malformed...
Another question: are there any negative side-effects if you don't run the database upgrade and just configure my new shipping services in 2.0? I tried to uninstall all shipping 1.x modules and I'm still able to see my shipping line items in old orders. This might be a quick fix for our problem, since we have very simple shipping rules.

Comments

rszrama’s picture

Hmm, yeah, for some reason it looks like you have a bad order or something - can you look in your commerce_order table and see if any orders are missing a type value?

stroobl’s picture

mysql> select distinct(type) from commerce_order;
+----------------+
| type           |
+----------------+
| commerce_order |
+----------------+
1 row in set (0.03 sec)

I've been looking through the table and the only thing strange I find for now is a few orders with an empty hostname field.

rszrama’s picture

commerce_order should be the only one available. Would a SELECT DISTINCT show empty values as well?

stroobl’s picture

Yes, i does. (I tried it on the hostname field)

fonant’s picture

I get this too. Will see what I can find.

fonant’s picture

Aha, in my database I have some commerce line items that reference deleted orders. This leads to the update trying to load a non-existent order, and then fails trying to save a null object with commerce_order_save().

So I fixed the update function 7100 by replacing:

    // If the order should be updated, trigger that now.
    if ($update_order) {
      $order = commerce_order_load($line_item_wrapper->order_id->value());
      commerce_order_save($order);
    }

with:

    // If the order should be updated, trigger that now.
    if ($update_order) {
      $order = commerce_order_load($line_item_wrapper->order_id->value());
      if ($order) {
         commerce_order_save($order);
      }
    }
stroobl’s picture

Solution in #6 works for me. Thanks, Fonant!

makangus’s picture

Status: Active » Needs review
StatusFileSize
new890 bytes

Same issue, patch from #6

rszrama’s picture

Status: Needs review » Fixed

Committed the patch; I'd recommend cleaning out those line items that reference non-existent orders.

Status: Fixed » Closed (fixed)

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