4.1.0
Although developer guide says you can use $belongs_many_many relationship for many_many_through lists as you used to, it looks like you can't.
When I do it as in the documentation (adding/updating relation classes with FQNs) it always complaining "belongs_many_many relation {$parentClass}.{$component} points to {$specification} without matching many_many"
If you set up an example like in the documentation but update relation classes with FQNs then you'll simply notice this issue.
Oops.. I just noticed that the fix is in the master branch when I was going to submit a PR. So it'd be pretty nice if we could get a release with this fix as latest release doesn't contain that update?
@priyashantha do you have a link to the PR where the fix was added?
@dhensby Sorry. I don't know a link for a PR. I think you got me wrong. I just wanted to submit a PR as I was in 4.1.0. But when I come to the file https://github.com/silverstripe/silverstripe-framework/blob/master/src/ORM/DataObjectSchema.php#L1015 the fix was there. So no needed to add any PR.
@dhensby I think this is not an issue anymore. But it'd be awesome if we'd have a release with that fix soon :)
OK - that line you linked to was introduce by https://github.com/silverstripe/silverstripe-framework/pull/7928 and that's been merged into 4 so will make the 4.2.0 release, whenever that is...
If there's an existing bug in 4.1 with this, it may be worth backporting
Yup. In latest 4.1.0 release the DataObjectSchema::getManyManyInverseRelationship() looks:
protected function getManyManyInverseRelationship($childClass, $parentClass)
{
$otherManyMany = Config::inst()->get($childClass, 'many_many', Config::UNINHERITED);
if (!$otherManyMany) {
return null;
}
foreach ($otherManyMany as $inverseComponentName => $nextClass) {
if ($nextClass === $parentClass) {
return $inverseComponentName;
}
}
return null;
}
which hasn't handle the through list.
Looks like this was fixed as part of a new feature, but @tractorcow鈥檚 suggestion here sounds like it could be suitable for a patch release if it fixes the issue https://github.com/silverstripe/silverstripe-framework/issues/7911#issuecomment-370600840
I'm not sure if this is related to this issue, if not I will open a new one.
In the docs it's stated that polymorphic many_many through relations are possible, but when trying the code sample (using SS 4.1.1) provided there I get the error
[Emergency] Uncaught InvalidArgumentException: many_many through relation SomeObject.Tags from references a polymorphic field TagMapping::Parent which is not supported
Do I have to enable this experimental feature somehow, or is this also something that's coming in 4.2.0?
I think polymorphic many_many_through is in 4.x only (4.2) at the moment.
Yes we can backport the fix; It'll re-enable belongs_many_many with many_many_through in 4.1. As suggested we'll just port back this code https://github.com/silverstripe/silverstripe-framework/blob/master/src/ORM/DataObjectSchema.php#L1014-L1020
No we can't fix it for polymorphic belongs_many_many though; Its currently impossible without massive refactoring. Unidirectional many_many through should work with polymorphic fine however.
Polymorphic many_many through is 4.2 only.
I hope that helps :D
@tractorcow That's awesome news. If this issue could be updated after backport done that be awesome. Thanks.
Closed by https://github.com/silverstripe/silverstripe-framework/pull/8140#event-1665766660
Most helpful comment
Closed by https://github.com/silverstripe/silverstripe-framework/pull/8140#event-1665766660