Hi,

I created a custom entity type (similar to 'node'). The MongoDB fields storage and drush migration worked perfectly - all data is now in MongoDB. But loading through entity_load() still fails.

I tried this in my custom.module:

/**
 * Needed to override Flatstore entity_load() to use MongoDB backend
 */
if (module_exists('mongodb_field_storage') && class_exists('CustomController')) {
  class MongoDbCustomController extends CustomController {
    function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
      return new MongoDbEntityLoader($this->entityType, $ids, $conditions);
    }

  }

  /**
   * Implements hook_entity_info_alter().
   */
  function custom_entity_info_alter(&$entity_info) {
    $entity_info['custom']['controller class'] = 'MongoDb' . $info['controller class'];
  }

}

I flushed caches etc. But then I get this error:

Call to undefined method MongoDB::load() in includes\common.inc on line 7623

Comments

Anonymous’s picture

Got one step closer. First problem was, my function custom_entity_info_alter() ran too late (before the actual entity info declaration). Now this works, but I get a new error:

Call to undefined method MongoDbEntityLoader::setFetchMode() in sites\all\modules\contrib\entity\includes\entity.controller.inc

Is this an entity.module issue, or not?

Anonymous’s picture

Category: support » bug

The problem was in MongoDbEntityLoader::execute()

It does this:

    ...
    $this->result = array_filter($entities);
    return $this;

I needed to change that to this:

    ...
    $this->result = array_filter($entities);
    return $this->result;

It seems that there is function fetchAllAssoc() which could do that, but its not called in my case? Is that a bug?

  function fetchAllAssoc() {
    return $this->result;
  }
Anonymous’s picture

Status: Active » Fixed

Well this issue is fixed for me, I implemented a custom class to do my custom stuff.

Status: Fixed » Closed (fixed)

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