aristeides, in #1107788-15: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo(), provided a database where when you add to the cart, you get the message

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() (line 110 of /home/rfay/workspace/commerce/sites/all/modules/entity/includes/entity.wrapper.inc).

I note that this warning is displayed when visiting the product line item type configuration page at admin/commerce/config/line-items/product/fields, even though the product reference module is in fact enabled:

Error message
Inactive fields are not shown unless their providing modules are enabled. The following fields are not enabled:
    Product (commerce_product) field requires the Autocomplete text field widget provided by commerce_product_reference module

@aristeides, if you would give us information on when you created this test site, how you created it, etc. that would be great.

Comments

heyyo’s picture

I have the same error by updating to last dev throw update UI (not drush):

    Notice: Undefined index: label in rules_entity_type_options() (line 493 of /home/quickstart/websites/xxxx.com/sites/all/modules/rules/modules/data.rules.inc).
    Notice: Undefined index: controller class in entity_type_supports() (line 68 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/entity.module).
    Warning: class_implements(): object or string expected in entity_type_supports() (line 68 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/entity.module).
    Warning: in_array() expects parameter 2 to be array, boolean given in entity_type_supports() (line 68 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/entity.module).
The following updates returned messages
commerce_order module
Update #7100

    All products have been loaded and saved with updated price component arrays.

Update #7101

    All line items have been loaded and saved with updated price component arrays.

Update #7102

    Failed: EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() (line 110 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/includes/entity.wrapper.inc).

heyyo’s picture

i finally succeed to install the last dev commerce by removing commerce directory and by redownloading a fresh commerce.tar.gz.
I was using drush before...

rfay’s picture

@heyyo, your issue is not related to this one. And it sounds like you've resolved it by using current code.

heyyo’s picture

It seems to be the same error:

Update #7102

    Failed: EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() (line 110 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/includes/entity.wrapper.inc).

and you're right I resolved it with fresh last commerce dev:

But these errors are still presents:

Notice: Undefined index: label in rules_entity_type_options() (line 493 of /home/quickstart/websites/xxxx.com/sites/all/modules/rules/modules/data.rules.inc).
    Notice: Undefined index: controller class in entity_type_supports() (line 68 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/entity.module).
    Warning: class_implements(): object or string expected in entity_type_supports() (line 68 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/entity.module).
    Warning: in_array() expects parameter 2 to be array, boolean given in entity_type_supports() (line 68 of /home/quickstart/websites/xxxx.com/sites/all/modules/entity/entity.module).

I will open another issue for this thanks,

rfay’s picture

@heyyo, yours is during an update. The original report was when adding to the cart. It's unfortunate that these EntityMetadataWrapperException errors give such poor information.

@rszrama, we should probably figure out a method to get a backtrace presented for these problems. Or stop using the wrapper.

mikejoconnor’s picture

Status:Active» Closed (duplicate)

Talked to rszrama. We think this is related to #1173208: Add a default field integrity checker.

Marking as duplicate.

jlab’s picture

I'm getting the same type of errors the site was running fine and proper even after migrating to Drupal-7.4 we use the commerce_product_display_manager to add the product display references.

The site was installed with the commerce_kickstart install profile.

We thought everything was running perfect for a while and the client started adding about 200+ new products and everything went smooth until this ugly error popped up it's head.

Now I'm not sure whether this is caused by commerce or commerce_product_display_manager.

Now we can't add any Product Display references to our products.

I installed the commerce_devel module to add the stack trace the error message is as follows:

Error
Error message

    Warning: Cannot modify header information - headers already sent by (output started at /var/aegir/platforms/commerce-kickstart-1.3-droplet/includes/common.inc:2565) in drupal_send_headers() (line 1039 of /var/aegir/platforms/commerce-kickstart-1.3-droplet/includes/bootstrap.inc). Backtrace:

    header('HTTP/1.1 500 Service unavailable (with message)') bootstrap.inc:1039
    drupal_send_headers(Array, 1) bootstrap.inc:974
    drupal_add_http_header('Status', '500 Service unavailable (with message)') commerce_devel.module:189
    _commerce_devel_log_error(Array, 1) commerce_devel.module:132
    _commerce_devel_exception_handler(Object)

    EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() (line 112 of /var/aegir/platforms/commerce-kickstart-1.3-droplet/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc). Backtrace:

    EntityMetadataWrapper->set(NULL) entity.wrapper.inc:419
    EntityStructureWrapper->__set('commerce_unit_price', NULL) commerce_product_reference.module:978
    commerce_product_line_item_populate(Object, Object) commerce_product_reference.module:944
    commerce_product_line_item_new(Object, 1) commerce_cart.module:1891
    commerce_cart_field_formatter_view('node', Object, Array, Array, 'und', Array, Array) field.default.inc:211
    field_default_view('node', Object, Array, Array, 'und', Array, 'search_index', NULL) field.attach.inc:198
    _field_invoke('view', 'node', Object, 'search_index', NULL, Array) field.attach.inc:375
    _field_invoke_default('view', 'node', Object, 'search_index', NULL, Array) field.attach.inc:1169
    field_attach_view('node', Object, 'search_index', 'en') node.module:1362
    node_build_content(Object, 'search_index', 'en') node.module:1286
    node_view(Object, 'search_index') node.module:2622
    _node_index_node(Object) node.module:2604
    node_update_index()
    call_user_func_array('node_update_index', Array) module.inc:795
    module_invoke('node', 'update_index') search.module:363
    search_cron()
    call_user_func_array('search_cron', Array) module.inc:819
    module_invoke_all('cron') common.inc:5042
    drupal_cron_run() system.module:3464
    system_run_automated_cron() common.inc:2571
    drupal_page_footer() common.inc:2544
    drupal_deliver_html_page(Array) common.inc:2435
    drupal_deliver_page(Array, '') menu.inc:518
    menu_execute_active_handler() index.php:21

The website encountered an unexpected error. Please try again later.

Is there any way to get this little beast out of the way?

Any help would be greatly appreciated. I could also provide DB dumps etc.

rfay’s picture

Status:Closed (duplicate)» Active

I think #1173208: Add a default field integrity checker is a great idea, but going to unmark this as a dup.

#7: The stacktrace you give is for a cron run. that doesn't seem to match what you're saying. Or there's something really bad going on.

If you get me the database I'll look at it. randy at randyfay.com, attach to the issue, send via dropbox, or whatever. Feel free to obfuscate the emails and passwords.

rfay’s picture

#7: I am unable to get any trouble using the database you sent. Please provide step-by-step instructions on how to get this error. I've created a product display node, and even have run cron.

jlab’s picture

The commerce side worked fine for quite a few days between us and the client it has already uploaded 200+ products. I have no idea to replicate this error step by step...

I will be loading a backup from when the site still worked before the errors, some of the people working along on the site loaded some contributed modules before the message started we will try and monitor and see if this error happens again.

I was hoping that I could somehow save the site and keep the 200+ uploaded products...

I tried migrating the site to a new platform but just got new error messages:

    Notice: Undefined index: line_item_type in commerce_cart_field_formatter_view() (line 1896 of /var/aegir/platforms/commerce-kickstart-1.4-droplet/profiles/commerce_kickstart/modules/contrib/commerce/modules/cart/commerce_cart.module).
    Warning: Cannot modify header information - headers already sent by (output started at /var/aegir/platforms/commerce-kickstart-1.4-droplet/includes/common.inc:2565) in drupal_send_headers() (line 1039 of /var/aegir/platforms/commerce-kickstart-1.4-droplet/includes/bootstrap.inc).
    EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() (line 328 of /var/aegir/platforms/commerce-kickstart-1.4-droplet/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc).

I will keep a close eye on what the other people involved are doing will post any useful information in re creating these errors as a reference for someone else who might run into this problem.

@rfay Thank you very much for looking at the database I appreciate that you took the time to look into it... I think I need to try and see how we got this error in the first place.

rszrama’s picture

Re: #10, the errors look related to another issue where someone updated to a new dev but didn't clear the cache before submitting the Add to Cart form. In that case, there would have been missing data from the cached field formatter info array - specifically the line_item_type variable. Did you do something similar? (I've since committed a follow-up patch to mitigate this error, but you should still run update.php when you update between devs in case there were any DB changes or the cache needs clearing.)

jlab’s picture

@rszrama Thank you I found the solution you described on another issue and it resolved my problem in #11.

The issue at #7 did pop up it's head again a bit later I was quite frustrated and almost tore my hair out at a stage luckily I made frequent backups almost every half an hour when the issue from #7 popped up again I built a new sandbox from the backup and started scrutinising the two installs. I finally realised that the error was caused by the client not providing a value for the price field for two of the products.

I tried to solve this from not happening in the future by mistake by making the price field mandatory but I end up with this message being displayed "The field Price is locked and cannot be edited."

Is there maybe a way to set this in the database? Because if the user forgets to add a price for the product I will end up with the error popping up again and being unable to add product displays until I find the products that doesn't have a price value.

Otherwise everything is now working super again...

rszrama’s picture

Ahh, yep, I ran into that same problem when dealing with an import situation for one of our clients. I bet we should probably make that field required and just default it to 0 or something. Will think about that...

rfay’s picture

Interesting - yeah, over in Commerce Feeds we've been trying to get to the bottom of products imported without price values, which causes havoc - #1183006: Price of zero gets dropped (because if empty() is used).

I do think probably Price itself should force the price if there isn't one.

rfay’s picture

And @personxx, congratulations on your success in getting to the bottom of this. @Ryan, thanks for the word about the cache issue.

Stalski’s picture

I have the same problem now in line 112 as well, and cache clear does not fix it.
You can reproduce it by submitting the shopping cart block with a add to cart forms in it. (but we don't do that ofcourse)

rfay’s picture

@Stalski, if you can post an exact description of the error you have and how to recreate it, it will help us. If it makes sense, I may ask you for a database so I can take a look at it.

mmll’s picture

I had the same problem.

1) Create product without a price.
2) Creating display with product reference field.
3) Add a reference to: New display node
4) You'll go to see the node what was created

And here it is:
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. funktsioonis EntityMetadataWrapper->set() (rida 112 / /var/www/htdocs/sites/all/modules/entity/includes/entity.wrapper.inc).

You can fix it by going back to your product list and filling up the price field.

rszrama’s picture

Status:Active» Fixed
rfay’s picture

Excellent!

marcjohnson’s picture

Applied rszrama's full patch #19 against 7.x-1.0-rc1.
Can confirm it worked marvelously.
Before patch, a missing price caused site outage with error message above. Now all is well. Thanks.

Status:Fixed» Closed (fixed)

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