Steps to repeat:
1. Install the relation, relation_ui, rules and rules_ui modules.
2. Create a Relation 'has page' from User to the Basic Page content type.
3. Go to admin/config/workflow/rules/components/add
4. Add a Rule with one parameter 'relation' of type 'Relation'
5. Add a Condition: Entity relation is of Bundle 'has page'
6. Add a Condition 'Data Comparison'. Select relation:endpoints:1:

Expected Results:
Rules should know that endpoint 1 of the Relation is a basic page, so I should be able to select the body field.

Actual Results:
There is nothing to select after relation:endpoints:1:

If I install the entityreference module and add an entityreference field referring to basic pages to the relation, that works fine - I can do a data comparison for relation:field-page-reference:body:value to my Rules.

Comments

tauno’s picture

Status: Active » Needs review
StatusFileSize
new1.39 KB

The property needs to be added to the array of properties for the relation type, not the bundles that are allowed in the endpoint.

mikran’s picture

Status: Needs review » Postponed (maintainer needs more info)

Well, that's a change but a little more description for reviewers is needed, why is it wrong originally & what kind of problems is it causing?

naught101’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Sorry, but this is mindless. The two variables contain exactly the same value, but $bundle makes more semantic sense in the context. If you really want to improve things here, then remove one of the variables all together. And provide a rationale for doing so.

Paul B’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new50 KB

The patch seems to solve my problem from https://drupal.org/node/2123701.
See screenshot.

mikran’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This lacks tests

mikran’s picture

Issue summary: View changes

Copied issue summary from https://drupal.org/node/2123701

adamgerthel’s picture

Issue summary: View changes

Tried the patch but it didn't work as expected for me.

milesw’s picture

Looks like there are a couple things going on:

1. Patch #2 fixes what is definitely a bug. The extra properties are being added to the wrong bundle. Instead of being added to the relation bundle, they're added to the bundle of the endpoint.

2. The "getter callback", relation_rules_get_specific_endpoints(), returns ALL endpoints instead of endpoints of the specified type.

These two things can really screw with Rules, Search API, etc. and are quite difficult to debug. The common symptom seems to be exceptions like:

EntityMalformedException while sending relation with ID 22: Missing bundle property on entity of type relation.

Here is a patch to address parts. Probably needs tests as @mikran mentioned.

Paul B’s picture

Status: Needs work » Needs review
mikran’s picture

Assigned: Unassigned » mikran

I'll do something to the getter callbacks

mikran’s picture

After further investigation I found out that d.o testbots are not even running these rules tests so the first priority is to get those running properly #2597055: Relation Rules tests are not working.

socialnicheguru’s picture

the patch does not apply to 11/2015 dev version

edvanleeuwen’s picture

I have applied the patch to the latest stable version. Now I am able to see the names of the endpoints and use them in a rule. However, during execution they are not populated.

djdevin’s picture

StatusFileSize
new2.66 KB

I rerolled this against the latest -dev and it did seem to work. I used it to make a rule that checks a role on the user being related before taking an action on the related user.

e.g., relation:endpoints-target-user:0 is now treated as a user in Rules.

Status: Needs review » Needs work

The last submitted patch, 14: relation_type_specific-1855418-14.patch, failed testing.

djdevin’s picture

I think I discovered what @edvanleeuwen saw, the properties are there but the data never is.

$array[] = entity_metadata_wrapper($endpoint['entity_type'], $endpoint['entity_id']);

entity_metadata_wrapper needs an entity as the 2nd argument so it isn't loading any data - just the properties.