Due to the change of entity_property_values_create_entity() in #1261192: Loosen entity_property_values_create_entity() the RESTWS tests fail for creating entities with unknown properties. I think we should keep the old behaviour as the service interface should be enforced by RESTWS. Unknown properties could have unknown side effects or maybe even security implications if they get into system.

So here is a patch that fixes the entity creation operation.

Comments

klausi’s picture

Status: Needs review » Needs work

ok, fago suggested to keep entity_property_values_create_entity() as it just works properly for $values arrays. So better do a comparison on the property info and the incoming values.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.72 KB

New patch: Compares incoming properties manually to the defined property info. Code is quite long for such a simple task :(

fago’s picture

Patch looks good to me. Maybe you can shorten the code by using the wrapper a bit, though.

E.g. you can use a wrapper like that to get the properties of a certain bundle:

$wrapper = entity_metadata_wrapper('node', NULL, array('bundle' => 'foo'));
$properties = $wrappert->getPropertyInfo();
fago’s picture

Status: Needs review » Needs work

or even better, we should not rely on the bundle that is incoming .. Thus just do:

$wrapper = entity_metadata_wrapper('node', $id);
$properties = $wrappert->getPropertyInfo()
klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.56 KB

Using the property info from a wrapper makes it only a little shorter. The id is not available, as this is a create operation.

klausi’s picture

Status: Needs review » Fixed

Committed an even shorter version, thx fago for the help. See http://drupalcode.org/project/restws.git/commit/8a4e96c

Status: Fixed » Closed (fixed)

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