asprin
Active member
I've 2 entitles whose table look like the following:
Foo
Bar
So, if we apply a composite filter on
Now the relations defined on
Now, if I'm logged in with an account whose
Why isn't the
Foo
sys_id | title |
---|---|
1 | first title |
Bar
sys_id | foo | user_id | category |
---|---|---|---|
1 | 1 | 45 | cat1 |
2 | 1 | 87 | cat1 |
So, if we apply a composite filter on
Bar
using foo = 1 AND user_id = 87
, I should be getting a single row from Bar
, i.e. in this case Bar sys_id = 2
row. This is the expectation.Now the relations defined on
Foo
are as follows:
PHP:
'Bars' => [
'entity' => 'Asprin\FB:Bar',
'type' => self::TO_MANY,
'conditions' => [['foo', '=', '$sys_id']],
'primary' => true
],
'VisitorBar' => [
'entity' => 'Asprin\FB:Bar',
'type' => self::TO_ONE,
'conditions' => [
['user_id', '=', \XF::visitor()->user_id],
['foo', '=', '$sys_id']
],
'primary' => true
]
Now, if I'm logged in with an account whose
user_id = 87
and do the following:$foo->Bars
--> I'm getting the correct result, i.e. 2 rows.$foo->VisitorBar
--> I'm getting wrong result, i.e. 1 row but upon dumping the result, the row with user_id = 45
is showing up. It should have been the one where user_id = 87
.Why isn't the
user_id
condition defined on the VisitorBar
relation not taking effect and it seems to be pulling the first row always irrespective of who is logged in.