Assume this code, somewhere in a module or in a tpl file:
$node_wrapper = entity_metadata_wrapper('node', node_load($nid));
echo $node_wrapper->property_that_does_not_exists->value();
We all get the error page (blocking everything else from execution) with message:
EntityMetadataWrapperException: Unknown data property property_that_does_not_exists. in EntityStructureWrapper->getPropertyInfo() (linea 349 di /var/www/vhosts/comelovuoitu.it/httpdocs/sites/all/modules/entity/includes/entity.wrapper.inc).
But we dont get any info about the file/function that raised the error asking for "property_that_does_not_exists".
I edited the getPropertyInfo() method in EntityStructureWrapper class to look like:
public function getPropertyInfo($name = NULL) {
$this->spotInfo();
if (!isset($name)) {
return $this->propertyInfo['properties'];
}
if (!isset($this->propertyInfo['properties'][$name])) {
$db = debug_backtrace(true, 3);
if(isset($db[2]))
{
$msg = '(' . $db[2]['file'] . ' on line ' . $db[2]['line'] . ')';
}
else
{
$msg = '';
}
throw new EntityMetadataWrapperException('Unknown data property ' . check_plain($name) . '.' . $msg);
}
return $this->propertyInfo['properties'][$name] + $this->info['property defaults'] + $this->propertyInfoDefaults;
}
So i get the file and the line where the unknown property has been invoked.
Comments
Comment #1
quiethero CreditAttribution: quiethero commentedI get the exact same problem and I was wondering how to properly locate and apply this fix to which exact class, module or file.
EntityMetadataWrapperException: Unknown data property field_published. in EntityStructureWrapper->getPropertyInfo() (line 339 of /home/mysite/public_html/sites/all/modules/entity/includes/entity.wrapper.inc).
Comment #2
Strae CreditAttribution: Strae commentedAFAIK the only way to do that _cleanly_ is to use debug_backtrace() (as in my first post) to dig backwards in the exception invocation.
You can to that inside the EntityMetadataWrapperException (about line 1107 of sites/all/modules/entity/includes/entity.wrapper.inc)
Comment #3
martin74 CreditAttribution: martin74 commentedEntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() (regel 122 van /var/www/vhosts/xxx/httpdocs/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc).
It after filtering on a product brand ( 46 items in it )
Brand has cross variation types
Line 118 - 128
* Set a new data value.
*/
public function set($value) {
if (!$this->validate($value)) {
throw new EntityMetadataWrapperException('Invalid data value given. Be sure it matches the required data type and format.');
}
$this->clear();
$this->data = $value;
$this->updateParent($value);
return $this;
}
Edit
I found my issue
It has to do with disabled products in the filtered entity