From 1307d3da41518a989f97ada5751b72703eae29ea Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 3 Oct 2008 16:11:46 +0000 Subject: [PATCH] BUGFIX Making sure that Dataobject->getManyManyJoin() inserts a valid database table for the relation - not all component classes returned by ComponentSet->ownerClass are valid tables (see r54797 and r60909 for previous commits on this issue) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63621 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index aadd88b3d..216d6638d 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -1266,10 +1266,11 @@ class DataObject extends ViewableData implements DataObjectInterface { list($parentClass, $componentClass, $parentField, $componentField, $table) = $this->many_many($componentName); + $baseComponentClass = ClassInfo::baseDataClass($componentClass); if($baseTable == $parentClass) { return "LEFT JOIN `$table` ON (`$table`.`$parentField` = `$parentClass`.`ID` AND `$table`.`$componentField` = '{$this->ID}')"; } else { - return "LEFT JOIN `$table` ON (`$table`.`$componentField` = `$componentClass`.`ID` AND `$table`.`$parentField` = '{$this->ID}')"; + return "LEFT JOIN `$table` ON (`$table`.`$componentField` = `$baseComponentClass`.`ID` AND `$table`.`$parentField` = '{$this->ID}')"; } }