OK, think I found the culprit. But before I commit, can the folk on this thread do some testing for me?
Around line 1012 in the admin list model (./administrator/components/com_fabrik/models/list.php), in the createLinkedElements() method is this:
PHP:
// if we are saving a new table and the previously found tables group is a join
// then don't add its elements to the table as they don't exist in the database table
// we are linking to
{
continue;
}
Locally, I have changed this to:
PHP:
// if we are saving a new table and the previously found tables group is a join
// then don't add its elements to the table as they don't exist in the database table
// we are linking to
// $$$ hugh - why the test for task and new table? When creating elements
// for a copy of a table, surely we NEVER want to include elements which were joined to the original,
// regardless of whether this is a new List? Bearing in mind that this routine now gets called from
// the makeNewJoin() method, when adding a join to an existing list, to build the "Foo - [bar]" join
// group, as well as from save() when creating a new List.
//if ($groupModel->isJoin() && JRequest::getCmd('task') == 'save' && JRequest::getInt('id') == 0)
if ($groupModel->isJoin())
{
continue;
}
... which I think is correct. This bit of code is in the branch where we already have the 'target' table known to Fabrik, so are copying existing elements (and giving them parent_id's), rather than working from the MySQL table schema for a table Fabrik doesn't know about. And when copying those existing elements, we shouldn't care if this is a new List save, we simply shouldn't be including elements from a joined group on the existing version of the List, we should only care about elements which are in non-joined groups, i.e. exist on the actual table we are joining to.
Of course, then there's the issue of whether we should then create any additional joins on this copy of the List (or this new join), coresponding to the joined groups we just ignored the elements for on the original. But that's a different issue.
Anyway - can y'all test that code change by applying it locally, and let me know if it a) fixes the problem, and b) if it has any unintended side effects - I don't think it will, but that's why they are 'unexpected'.
Thanks,
-- hugh