The views_ui_config_item_form() function (in admin.inc) is responsible for constructing the "Relationship:" dropdown that's shown, when applicable, on every field form.

However, that function checks for applicability thus:

$base_fields = views_fetch_fields($base, $form_state['type']);
if (isset($base_fields[$handler->table . '.' . $handler->field])) {

Instead of thus:

$base_fields = views_fetch_fields($base, $form_state['type']);
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {

While doing $handler->table . '.' . $handler->field is fine for most cases, there's one instance where it fails: a relationship handler may overwrite $this->field by $this->definition['relationship field']. So doing $handler->table . '.' . $handler->field in this case will fail to find this relationship in any table.

(This can be seen in a bug report in the Flag module's queue.)

The "relationship field" definition is quite handy (it's like the "real field" definition), so this bug might bother many more people in the future.

(Incidentally, the same problem happens with the "relationship table" definition, but I didn't mention it because it'd be rarer to use this definition. The patch fixes this case as well.)

The patch fixes this by switching to $item['table'] . '.' . $item['field'].

CommentFileSizeAuthor
relationships_missing.diff1.5 KBmooffie

Comments

mooffie’s picture

The "relationship field" definition is quite handy (it's like the "real field" definition), so [...]

BTW, why doesn't the Relationship handler use the "real field" definition?

mooffie’s picture

I've just stumbled upon an issue where a user using VotingAPI complains about the same symptoms: The "Relationship:" dropdown doesn't show for him.

It might very well be the same bug I'm describing here, because VotingAPI too uses the 'relationship field' definition.

merlinofchaos’s picture

BTW, why doesn't the Relationship handler use the "real field" definition?

I was asking myself that same question while working with the translation relationships just this week, and I do not have an answer for the question. It may be oversight.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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