I'll preface this by saying that I'm not at all on firm ground in my understanding of what is going on here, but I think I have found an issue that can cause conflicts with multiple modules that are all relying on Entity.
In our setup we were having an issue with field_collection (similar to this: #1785698: Missing bundle property on entity of type field_collection_item line 7562) and started digging into the problem. I landed on the following code in entity.module:
if (isset($info['creation callback'])) {
return $info['creation callback']($values, $entity_type);
}
elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
return entity_get_controller($entity_type)->create($values);
}
In our case the problem is that class_implements($info['controller class'])
returns an array containing only DrupalEntityControllerInterface. When I dug a little deeper it *seems* that this is happening because we are using the SPS module and through some magic (this is the part where I'm very shaky in my understanding) they are extending the controller class further to such a degree that class_implements($info['controller class'])
no longer returns what entity.module expects. A simple (and seemingly more appropriate) solution was to use this code instead: class_implements($info['controller class base'])
. This way it does not matter to what degree third-party modules extend the controller class, EntityAPIControllerInterface is always in the array returned by class_implements().
I primarily tested this patch by installing entity, field collection & sps. Then I created a content type with a field_collection field. Without this patch, I got a "missing bundle..." error when I tried to add/edit/view/delete a node. With this patch, life is good.
Comment | File | Size | Author |
---|---|---|---|
#6 | entity-controller-class-base.patch | 6.53 KB | bleen |
#4 | entity-controller-class-base.patch | 4.96 KB | bleen |
#2 | entity-controller-class-base.patch | 4.95 KB | bleen |
entity-controller-class-base.patch | 6.05 KB | bleen | |
Comments
Comment #2
bleen CreditAttribution: bleen commentedlets see if testbot likes this better
Comment #4
bleen CreditAttribution: bleen commentedI missed an "isset" ...
Comment #6
bleen CreditAttribution: bleen commentedThis patch takes a slightly more sophisticted approach. If $info['controller class base'] exists, then use that, otherwise use $info['controller class']
This patch passes tests locally.
Comment #7
bleen CreditAttribution: bleen commented...just fixing title
Comment #8
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #9
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch in #6 to entity.module applied cleanly to the latest entity 7.x-1.x-dev and (if still relevant) needs review.