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'].
| Comment | File | Size | Author |
|---|---|---|---|
| relationships_missing.diff | 1.5 KB | mooffie |
Comments
Comment #1
mooffie commentedBTW, why doesn't the Relationship handler use the "real field" definition?
Comment #2
mooffie commentedI'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.
Comment #3
merlinofchaos commentedI 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.
Comment #4
merlinofchaos commentedCommitted. Thanks!
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.