Active
Project:
RESTful Web Services
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Sep 2012 at 21:51 UTC
Updated:
19 Sep 2012 at 21:51 UTC
The patch in #1506190: Don't allow to create Entities without Bundles and commit http://drupalcode.org/project/restws.git/commit/2318d17 is incorrect.
The property that refers to the bundle is in entity keys, not bundle keys (api). Bundle keys refers to the property on the bundle itself, which may or may not match the entity key bundle. This will fail for entities like Organic group membership and membership type IIRC (i.e. $entity->type == $entity_type->name).
I don't have time to make a patch at the moment, but as an example. I'll try to roll a patch some time.
$entity_info = entity_get_info($this->entityType);
if (isset($entity_info['entity keys']['bundle'])) {
if (!array_key_exists($entity_info['entity keys']['bundle'], $values)) {
throw new RestWSException('Missing bundle: ' . $entity_info['entity keys']['bundle'], 406);
}
}