mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUG $db in extensions not inited early enough (#7598)
When querying DataObjects by a generic parent class (like SiteTree for instance), fields added via $db set on child classes wouldnt appear. This is because Object::__construct wasnt called early enough in DataObject::__construct, so extensions werent initialised when $db was first accessed
This commit is contained in:
parent
ea910a5174
commit
890f7e3919
@ -295,6 +295,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* don't have their defaults set.
|
||||
*/
|
||||
function __construct($record = null, $isSingleton = false, $model = null) {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
// Set the fields data.
|
||||
if(!$record) {
|
||||
$record = array(
|
||||
@ -345,8 +348,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
HTTP::register_modification_date($record['LastEdited']);
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
// Must be called after parent constructor
|
||||
if(!$isSingleton && (!isset($this->record['ID']) || !$this->record['ID'])) {
|
||||
$this->populateDefaults();
|
||||
|
Loading…
x
Reference in New Issue
Block a user