Problem/Motivation

It appears the relation type information is not returned if the relation types are stored in the cache tables (e.g. after enabling or installing from a feature).

I have observed this in at least two situations:
- when writing scripts to insert relations
- when re-exporting a feature that includes the relation type

Proposed resolution

I assume the fix is somewhere in relation_type_load() and relation_get_types() or the routines they call (e.g. ctools_export_crud_load_multiple()).

Remaining tasks

Fix, review, and test.

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#11 1348808-relation_list_types-11.patch599 bytesjelle_s

Comments

naught101’s picture

How are you trying to access the relation type information? What other modules do you have installed (Entity API?)

solotandem’s picture

From the script to insert relations, we are calling relation_save(). The save fails because relation_endpoints_field_validate() generates errors as the relation type information is not available when only in the cache.

Similarly, Features is unable to re-export the relation type when stored only in cache.

We are using entity-1.0-rc1 and relation (latest with a few patches as posted in issue queues).

naught101’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry, I'm not seeing that. Can you provide a detailed step-by-step on how to produce one or more of those errors?

solotandem’s picture

Steps:
- export relation types as a feature
- flush database and re-install site
- import/refresh the relation types feature (this leaves relation type definitions in cache only)
- run script to insert relations (this fails as indicated in #2)
- re-export the relation types feature (this fails as indicated in #2)

matglas86’s picture

Component: Code » API
Priority: Normal » Major

I have the same problem. The types are shown in the relation list but this loads it through relation_entity_info. When I call relation_list_types and they are only instanciated through the feature they don't show up. They are not in the table relation_type.

diwant’s picture

Me as well. I am able to relation_create and relation_save with the machine name of the phantom relation.

naught101’s picture

wtf do we have both relation_list_types and relation_get_types?? matglas86, can you check whether relation_get_types() reports your feature-based relation type properly? it should, and then we can just make relation_list_types use that, or get rid of it al together..

naught101’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing after a year of no activity. Re-open if it's still a problem.

jelle_s’s picture

Status: Closed (cannot reproduce) » Active

wtf do we have both relation_list_types and relation_get_types?? matglas86, can you check whether relation_get_types() reports your feature-based relation type properly? it should, and then we can just make relation_list_types use that, or get rid of it al together..

I have the same problem, with the same steps to reproduce as in #4. As you say, relation_list_types does not load the ctools exportables. So please make relation_list_types use relation_get_types and mark it as deprecated, so other contrib modules get a chance to update before dropping the function all together.

naught101’s picture

I don't have time to work on this at the moment. Feel free to post a patch, and I'll add it if it looks good.

jelle_s’s picture

StatusFileSize
new599 bytes

I looked again, and the function relation_get_types in fact is different from relation_list_types:

relation_get_types:

@return
    An array of relation type records in the same format as expected by
   relation_type_save(), keyed by relation_type.

relation_list_types:

@return
    Array of relation type names in the format "Label (type)", keyed by
    relation_type.

And relation_list_types is still different from relation_get_types_options because this function does not include the "(type)" after the label. The function relation_list_types is not used in the relation module itself, however, I've chosen to just fix the function in this patch, as it might be used in contrib (I know it's used in crm_core_relationship_ui from the crm_core module).

jelle_s’s picture

Status: Active » Needs review

Issue status

naught101’s picture

Status: Needs review » Active

Committed to 7.x-1.x 807f7a1 (this function doesn't exist in d8). Thanks.

But I guess that doesn't resolve the original issue, so re-opening.

mikran’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

This is really old issue. Many other issues have been since fixed that deal with relations exported to features so I'd imagine this is also resolved by now.