After creating a search api index based on the relation entity, the following error occurs :

EntityMetadataWrapperException: Missing data values. in EntityMetadataWrapper->value() (line 73 of entity/includes/entity.wrapper.inc)

This error won't leave until you remove the index.

Comments

Letharion’s picture

Assigned: Unassigned » Letharion
jsacksick’s picture

Assigned: Letharion » Unassigned

Here is the debug_backtrace() :

http://pastebin.com/th0vkBkG

damien tournoud’s picture

Title: Error when trying to create a search api index based on the relation entity » Expose the relation-type specific fields
Status: Active » Needs review
StatusFileSize
new3.33 KB

I looked into this more. One of the problem is that relation only exposes the generic list<entity> instead of the entity-type specific ones. As a consequence you cannot introspect the relation structure.

Moreover, the relation module doesn't properly exposes the rid property, so Search API fails to index it.

damien tournoud’s picture

StatusFileSize
new3.25 KB

Same patch with cleanup.

jsacksick’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.03 KB

What's the status of this issue ? Tested, just need to correct a line in the getter callback which should return the entity_ids instead of entities directly.

Here is the new patch.

chx’s picture

Status: Reviewed & tested by the community » Needs work

This is nice but I really dislike the $bundle_properties = &$info['relation']['bundles'][$bundle]['properties']; construct (will file issue against entity API as well) why can't we just do $info['relation']['bundles'][$bundle]['properties']; = $bundle_properties at the end?

damien tournoud’s picture

Status: Needs work » Reviewed & tested by the community

No we cannot because there could be some properties there to begin with. We could += at the end, but that's going to be ugly very quick. I think this construct is the cleanest we can do.

chx’s picture

Status: Reviewed & tested by the community » Needs work

There could be some properties coming from where?


function relation_entity_property_info() {
  $info = array();
  $properties = &$info['relation']['properties'];

  $properties = array(
    'relation_type' => array(
      'label' => t('Relation type'),
      'type' => 'token',
      'description' => t("The type of the relation."),
      'setter callback' => 'entity_property_verbatim_set',
      'setter permission' => 'administer nodes',
      'options list' => 'relation_rules_get_type_options',
      'required' => TRUE,
      'schema field' => 'relation_type',
    ),
    'endpoints' => array(
      'label' => t('Endpoints'),
      'type' => 'list<entity>',
      'description' => t("The endpoints of the relation."),
      'setter callback' => 'relation_rules_set_endpoints',
      'getter callback' => 'relation_rules_get_endpoints',
      'setter permission' => 'administer nodes',
      'required' => TRUE,
    ),
  );

  return $info;
}

this is the current code and I wish it didnt look that , either. There is no incoming info argument, there is no previous setting of $info['relation']['bundles']. And yes. I would rather fight this here and now than in the entity API where, as I said, I will go next.

You will burn yourself so badly with these unneeded references one day :/

chx’s picture

Status: Needs work » Fixed

Committed. (Against my better judgement.)

Status: Fixed » Closed (fixed)

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

chx’s picture

Title: Expose the relation-type specific fields » Expose the relation-type specific fields breaks with eva
Status: Closed (fixed) » Needs work

Install eva and this breaks. Rolled back this along with 606d433f65fbb511511397e52a35ea75bb3b5fcc #1265434: Expose relation in an entity list wrapper containing all related entities because I think that one depended on this one.

Edit: reproduction steps, click the 'display fields' of a ctools-exported relation type (might work with db relation type too I didnt check) and click save. If you have eva installed then you get a WSOD.

Edit2: Here is the patch to apply on top of HEAD to reproduce the problem.

chx’s picture

upon field info cache clear, eva calls get views which leads to entity api call the properties callback which leads to a call to relation_get_types which calls field_info_instance. The circle is now complete.

jsacksick’s picture

StatusFileSize
new8.19 KB

This patch seems to work with me.
Properties per bundle are now added in the hook_entity_property_info_alter(). instead of hook_entity_property_info()..
Anyway, relation_type_ensure_instance() shouldn't be called in relation_get_types() because relation_get_types() is itself called in the hook_entity_property_info() and calling field_info_instance (which is in relation_type_ensure_instance) in an entity info hook is not a good idea and could cause issues just like this one.

chx’s picture

Status: Needs work » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

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

chx’s picture

Title: Expose the relation-type specific fields breaks with eva » Add tests for Expose the relation-type specific fields
Component: Code » API
Category: bug » task
Status: Closed (fixed) » Active
Issue tags: +Needs tests
kalman.hosszu’s picture

Status: Active » Needs review
StatusFileSize
new1.81 KB

Hi,

I attached a patch to test the new feature.

Kálmán

chx’s picture

Status: Needs review » Fixed

Thanks a ton.

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