EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of /app/www/d7/ibis/production/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
This exception occurs with a URL like this: node/32643text
Backtrace from og:
1. og_ui_og_ui_get_group_admin()
2. og_is_group_default_access()
3. entity_metadata_wrapper()
4. new EntityDrupalWrapper()
5. EntityMetadataWrapper::set()
6. EntityMetadataWrapper::validate()
7. entity_property_verify_data_type()
This return FALSE with a path like node/32643%3Fpage%3D1 or node/32643lol but only when node/32643 is valid.
It's being caused by the fact that node_load() works with the gammy path, so you don't get "Page not found", but then entity_property_verify_data_type() fails because it doesn't look like an int (see line 270 of entity.wrapper.inc).
I've identified this bug via og, but presumably it can be caused by other modules as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2214417.diff | 1 KB | drumm |
Comments
Comment #1
mossy2100Ok the bug occurs because this code in include/entity.inc works even if id looks like '9999lol':
(lines 184-193)
// Load any remaining entities from the database. This is the case if $ids
// is set to FALSE (so we load all entities), if there are any ids left to
// load, if loading a revision, or if $conditions was passed without $ids.
if ($ids === FALSE || $ids || $revision_id || ($conditions && !$passed_ids)) {
// Build the query.
$query = $this->buildQuery($ids, $conditions, $revision_id);
$queried_entities = $query
->execute()
->fetchAllAssoc($this->idKey);
}
Mysql accepts the value 9999lol as 9999 and the query returns, assuming there is a matching entity with id=9999.
So it's arguably a bug a core - perhaps there should be a check here that $ids contains only ints.
Comment #2
paulovg12 commentedI have the same issue, I deleted some of the previous contents, ( I believe there was an OG update a few days ago). The OG update was March 18 the update a few days ago was something else maybe Entity API.
Mine use to work fine before the deletion and update.
message is below:
Type node
Date Wednesday, April 9, 2014 - 02:49
User pvgervasio
Location https://secure144.inmotionhosting.com/~dacapo5/rc/node/add/photos?og_gro...
Referrer https://secure144.inmotionhosting.com/~dacapo5/rc/node/add/photos?og_gro...
Message EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of /home/dacapo5/public_html/rc/sites/all/modules/entity/includes/entity.wrapper.inc).
Severity error
Hostname 218.186.196.224
Operations
I did some testing and temporarily modified the I added the following in the entity wrapper inc file :
it gave me this
Entity Wrapper: Invalid data value given: Array
Entity Wrapper: Invalid data value given info [type]:
Entity Wrapper: Invalid data value given info:
Entity Wrapper: Invalid data value given type:
Entity Wrapper: Invalid data value given id:
Entity Wrapper: Invalid data value given data:
The value Array in $value is either empty array or the string "Array"
Comment #3
1kenthomas commentedSee https://drupal.org/node/1925412 ; moving this to OG queue.
(Likely this is due to OG or another module not sanitizing its data, and should be reported there ...)
Comment #4
shushu commentedCan you verify the proper OG version ?
Comment #5
hiramanpatilI am getting error when assigning mulitple roles to the user. If use has single role then page loads properly. But as soon as I assign second role to the user and logs in with same user from front-end it shows below error message:-
Please let me know if anyone has same issue or any solution.
Comment #6
f1l1pp0 commentedI am also experiencing this problem, and I believe the reason is the same as hiramanpatil described: since I gave an additional role to some users, an EntityMetadataWrapperException occurs everytime a user with multiple roles creates a new post (group content).
Did anyone find a solution?
The problem occurs on a Drupal Commons distribution installed a couple of months ago which runs the latest version of Organic Groups.
Thanks!
Comment #7
drumm#5 and #6 may be a separate issue, I haven't tested users with multiple roles.
The original issue report, “This exception occurs with a URL like this: node/32643text” is affecting Drupal.org. Instead of the regular core behavior of loading up node 32643, this exception happens.
Comment #8
drummThis patch fixes the issue by casting the input to the expected int.
Comment #10
drummActually, this was fixed by #2242237: EntityMetadataWrapperException when OG UI uses invalid group IDs, which has been committed to 7.x-2.x, but is not in 7.x-2.7.