$data['mytable']['table']['join'] = array(
'anothertable' => array(
'handler' => 'views_join',
'left_table' => 'anothertable',
'left_field' => 'base_nid',
'field' => 'base_nid',
'extra' => array(
'sid = 9',
),
),
);
This looks like a correct definition when extending the ON condition for a join.
Trying this I get a "array_key_exists() expects parameter 2 to be array, string given in views_join->build_join() (line 1548.." warning. While traversing the extra array in a foreach loop, "if (!array_key_exists('table', $info))" checks if there is a table attribute. But when passing an array of strings as the extra parameter (described as a possibility in the documentation) the $info variable is a string and not an array.
Maybe I am wrong and did not understand the docs, but a solution would be to extend the "if" part:
if (!is_array($info) || !array_key_exists('table', $info))
This could result in some unexpected behaviour. I could help figuring out a solution if this is a real bug. Otherwise enlighten me ;)
Cheers,
schlicki
Comment | File | Size | Author |
---|---|---|---|
#15 | views-n1930288-15.patch | 415 bytes | CvW |
#10 | views-n1930288-10.patch | 3.13 KB | DamienMcKenna |
| |||
#8 | views-1930288-8.patch | 2.89 KB | MustangGB |
|
Comments
Comment #1
ralf.strobel CreditAttribution: ralf.strobel commentedI also just noticed this. The documentation does not match the implementation.
Doc says: "extra: An array of extra conditions on the join. Each condition is either a string that's directly added, or an array of items..."
But the code only checks whether the entire variable "extra" is a string. If so, then it is added directly as described. However, if extra is an array, then every item is expected to be an array.
Comment #2
kristiaanvandeneyndeYup, this is a bug.
The current code checks if 'extra' is an array or string and then runs some logic on it.
Instead, it should know 'extra' is an array and check whether each element is an array or string.
Attached is a patch that fixes this.
Comment #3
MustangGB CreditAttribution: MustangGB commentedComment #4
MustangGB CreditAttribution: MustangGB commentedComment #5
colanWe've recently switched our testing from the old qa.drupal.org to DrupalCI. Because of a bug in the new system, #2623840: Views (D7) patches not being tested, older patches must be re-uploaded. On re-uploading the patch, please set the status to "Needs Review" so that the test bot will add it to its queue.
If all tests pass, change the Status back to "Reviewed & tested by the community". We'll most likely commit the patch immediately without having to go through another round of peer review.
We apologize for the trouble, and appreciate your patience.
Comment #6
kristiaanvandeneyndeRe-uploading the same patch then.
Comment #7
kristiaanvandeneyndeComment #8
MustangGB CreditAttribution: MustangGB commentedStraight re-roll.
Comment #9
DamienMcKennaBumping to the next release.
Comment #10
DamienMcKennaReroll.
Comment #11
kristiaanvandeneyndeComment #12
DamienMcKennaCommitted. Thanks.
Comment #15
CvW CreditAttribution: CvW as a volunteer commentedI still getthe warnings when $this->extra is a string.
The PHP manual says about foreach:
When $this->extra is cast as array, the warning disappears.