Fixes a bug where eagerloading an empty many_many relation would result in an exception.
It was caused by adding 'AND ' . $childIDField . ' IN (' . $fetchedIDsAsString . ')' to the SQL query for fetching join rows, without checking that we had actually found any child IDs in the first place.
Can be triggered by either having an empty relation list, or by causing the list to be empty by manipulating the eagerloaded query with the new syntax.
Having this in _config.php is enough to reproduce the original bug:
<?php
use SilverStripe\Security\Group;
$items = Group::get()->eagerLoad('Roles');
foreach ($items as $item) {
// no-op
}
Fixes a bug where eagerloading an empty many_many relation would result in an exception. It was caused by adding
'AND ' . $childIDField . ' IN (' . $fetchedIDsAsString . ')'
to the SQL query for fetching join rows, without checking that we had actually found any child IDs in the first place.Can be triggered by either having an empty relation list, or by causing the list to be empty by manipulating the eagerloaded query with the new syntax.
Having this in
_config.php
is enough to reproduce the original bug:Issue