|Component:||Entity property wrapper|
entity_metadata_wrapper accepts entity id as parameter, so entity_metadata_wrapper('node', 17) lazyloads node with id 17.
This does NOT work if the entity declares a name column, like Countries does. Then a name must be given, the id won't work.
I wasn't aware of that. So was the author of organic groups 2.x.
So we have dozends of lines like
return entity_metadata_wrapper($object->group_type, $object->gid);
which break for entities-with-names.
This is a general problem that always occurs if we if entity type is a variable: We can't rely on ID autoloading.
We can fix this in different ways:
1) don't use lazyloading. this will deny ease of use and merits of lazyloading for a big class uf use cases.
2) always expect id. this is the cleanest, but may break code.
3) if entity declares a name, still use id as fallback.
this will still create ambiguity for fieldless entities that use string ids but that's much less pain.
What do you think about 2) or 3)?
EDIT: i've seen that entity_load_single() says
In case the entity
* type has specified a name key, both the numeric id and the name may be
so 3) is the way to go is uppose.
(parent issue: #1937784: Allow uppercase entity names)