With the latest -dev version of Entity module these errors appear when adding a product in a order which is in cart status:
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 179 of /webs/drupalcommerce/includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 355 of /webs/drupalcommerce/includes/entity.inc).
Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2039 of /webs/drupalcommerce/includes/database/database.inc).
Tested with latest dev version of drupalcommerce (Ryan's branch) and also with alpha4.
It seems that the problems are located in the commerce_cart_commerce_order_presave invoke:
$wrapper = entity_metadata_wrapper('commerce_order', $order);
// Get the order directly from the database and compare with the current one.
$unchanged_order = reset(commerce_order_load_multiple(array($order->order_id), array(), TRUE));
$unchanged_wrapper = entity_metadata_wrapper('commerce_order', $unchanged_order);
The errors appear as well when changing an existing order to "Shopping cart" status or adding product line items to an existing order already shopping cart status.
Comments
Comment #1
bellHead commentedI believe that #1013428: EntityListWrapper::value() lacks support for fully loaded entities is the cause of this issue.
Not marking this duplicate quite yet since it may still be expected behaviour on Entity's part and a fault in Commerce.
Comment #2
rszrama commentedI can confirm the issue, but I'm at a loss as to where the fix will come in. It seems to be a result of changes in entity.wrapper.inc, but that could be a red herring. Reverting that file to revision 1.1.2.2 made the errors disappear, so we'll see what fago says next. : )
Comment #3
rszrama commentedOk, this patch seems to fix the problem... running it by fago and doing some Rules testing.
Comment #4
rszrama commentedAlrighty, I fiddled with this in Rules and could iterate the list just fine. I'm marking this fixed with the commit of that patch above, and I'll play with it some more to see if we really even need to define the line_items property ourselves.
Comment #5
pieterdcYour patch fixes the error of this issue, but it also removes the code I helped to introduce to fix #979846: Rules line items list
Sadly, but logically, your patch reintroduces the "conflict" between line items and the Rules module.
So, either this or the other issue needs reopening, I guess.
Comment #6
rszrama commentedAhh, poo... I hoped it would be a clean fix, but I knew we had just added that code in for some reason not too long ago. This patch was based on fago's comments in #1013428: EntityListWrapper::value() lacks support for fully loaded entities ... but you know, after our chat this afternoon, I wonder if the solution isn't to just remove this code entirely and instead require an "Entity has field" condition to add the line item list to the data selector. I think that might be what fago was referring to in some of his comments in that other issue.
Comment #7
rszrama commentedAs far as I can tell, my hunch in #6 is right... I've removed the line_items array from the order property info definition. Line item data can be properly accessed and modified via Rules and the Entity Metadata Wrapper now. For Rules you just have to use the "Entity has field" condition or check the bundle type.
For more information, refer to my comments at http://drupal.org/node/1015574#comment-3918438 and http://drupal.org/node/1013428#comment-3918450.
Comment #8
elvis2 commentedIf you remove the $properties['line_items'] array in commerce_order_entity_property_info() AND the switch case for 'line_items' in commerce_order_get_properties(), the cart does work. But, I am now getting this error:
'Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column \'commerce_line_item.line_item_id\' in \'field list\''
in views_plugin_query_default->execute() (line 1314 views/plugins/views_plugin_query_default.inc).
Is this strictly a views issue?
Comment #9
elvis2 commentedNevermind, the latest views 7.x-3.x-dev fixed this issue with #6 fix. There is no need to remove the switch case for 'line_items' in commerce_order_get_properties()
Comment #10
pieterdcYay!