{"action":"created","issue":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/2856","repository_url":"https://api.github.com/repos/silverstripe/silverstripe-framework","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/2856/labels{/name}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/2856/comments","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/2856/events","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/2856","id":27733129,"number":2856,"title":"Unable to have an Abstract Data Object","user":{"login":"oilee80","id":1453382,"avatar_url":"https://avatars.githubusercontent.com/u/1453382?v=3","gravatar_id":"","url":"https://api.github.com/users/oilee80","html_url":"https://github.com/oilee80","followers_url":"https://api.github.com/users/oilee80/followers","following_url":"https://api.github.com/users/oilee80/following{/other_user}","gists_url":"https://api.github.com/users/oilee80/gists{/gist_id}","starred_url":"https://api.github.com/users/oilee80/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oilee80/subscriptions","organizations_url":"https://api.github.com/users/oilee80/orgs","repos_url":"https://api.github.com/users/oilee80/repos","events_url":"https://api.github.com/users/oilee80/events{/privacy}","received_events_url":"https://api.github.com/users/oilee80/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/change/patch","name":"change/patch","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2014-02-17T16:39:49Z","updated_at":"2016-08-17T01:02:44Z","closed_at":"2014-11-15T00:28:44Z","body":"Due to how the DataObject inheritance works it is not possible to have an abstract DataObject. The use case for this would be:\r\n\r\n```php\r\nabstract class MediaLinkRelationship extends DataObject {\r\n    private static $db = array('Title' => 'Varchar','AltName' => 'Varchar',.....);\r\n    private static $has_one = array('MediaItem' => 'MediaItem');\r\n}\r\nclass PageMediaLinkRelationship extends MediaLinkRelationship {\r\n    private static $has_one = array('Parent' => 'Page');\r\n}\r\nclass AnotherDataObjectMediaLinkRelationship extends MediaLinkRelationship {\r\n    private static $has_one = array('Parent' => 'AnotherDataObject');\r\n}\r\n```\r\n\r\nThe error occurs during build as it is trying to instantiate the abstract class (MediaItemRelationship) during DatabaseAdmin::doBuild()."},"comment":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/comments/240285240","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/2856#issuecomment-240285240","issue_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/2856","id":240285240,"user":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"created_at":"2016-08-17T01:02:44Z","updated_at":"2016-08-17T01:02:44Z","body":"It would need to be master, since any existing code could rely on `singleton($class)` not to crash."}}
{"actor":{"display_login":"tractorcow"}}