silverstripe/silverstripe-framework — pull request #2250 by madmatt (2013-07-20 05:12:28+00:00)
Title: BUGFIX: Fix 'Orphaned $belongs_many_many' error when trying to get a many_many relation specified on a parent class

Consider the following project:
```php
'Page_SpecificTag'
);
}

class Page_Tag extends DataObject {
private static $db = array(
'Title' => 'Varchar(100)'
);

private static $belongs_many_many = array(
'Pages' => 'Page'
);
}

class Page_SpecificTag extends Page_Tag {}

/**
* Here for example only - this class does not contribute to the error,
* but provides the easiest way to see the error in the wild.
*/
class Page_TagAdmin extends ModelAdmin {
private static $managed_models = array(
'Page_Tag',
'Page_SpecificTag'
);

private static $url_segment = 'tag-admin';

private static $menu_title = 'Tag Admin';
}
```

Running this code appears to work fine, except when you try and execute a link back from the Page_SpecificTag to the ManyManyList object provided by ->Pages(). You can see this by using the ModelAdmin, and trying to create or edit a Page_SpecificTag. Creating or editing a Page_Tag object works fine, but doing either action to a Page_SpecificTag doesn't work.

The error returned is from DataObject::many_many().

A very simple fix to DataObject and test case to prove the fix works (fails before, works after) will be forthcoming.