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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, entity-controller-class-base.patch, failed testing.

bleen’s picture

Status: Needs work » Needs review
FileSize
4.95 KB

lets see if testbot likes this better

Status: Needs review » Needs work

The last submitted patch, entity-controller-class-base.patch, failed testing.

bleen’s picture

Status: Needs work » Needs review
FileSize
4.96 KB

I missed an "isset" ...

Status: Needs review » Needs work

The last submitted patch, entity-controller-class-base.patch, failed testing.

bleen’s picture

Status: Needs work » Needs review
FileSize
6.53 KB

This 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.

bleen’s picture

Title: Use "controller class base" instead of "controller class" when checking for EntityAPIControllerInterface » Check "controller class base" as well as "controller class" when checking for EntityAPIControllerInterface

...just fixing title

SocialNicheGuru’s picture

Chris Matthews’s picture

The 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.