When a record belongs to multiple many_many (and maybe has_many) relations and you eagerload it and chained relations from it, you can end up in a scenario where the eagerloaded data doesn't get added to some of the relation lists it belongs to.
More details in the linked issue.
Manual testing steps
Add a breakpoint on DataList::getFinalisedQuery()
Run this code
use SilverStripe\Security\Member;
$list = Member::get()->eagerLoad('Groups.Permissions');
foreach ($list as $member) {
foreach ($member->DirectGroups() as $group) {
foreach ($group->Permissions() as $perm) {
echo '';
}
}
}
Check the trace each time the breakpoint is hit. It should only be hit once directly from the above code.
You could also add a breakpoint in the above code itself, and check that each list being looped over (with exception for the top loop) is an instance of EagerLoadedList, not DataList.
[x] All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
Description
When a record belongs to multiple many_many (and maybe has_many) relations and you eagerload it and chained relations from it, you can end up in a scenario where the eagerloaded data doesn't get added to some of the relation lists it belongs to. More details in the linked issue.
Manual testing steps
DataList::getFinalisedQuery()
You could also add a breakpoint in the above code itself, and check that each list being looped over (with exception for the top loop) is an instance of
EagerLoadedList
, notDataList
.Issues
Pull request checklist