mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-03 14:48:38 +02: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.
|
* don't have their defaults set.
|
||||||
*/
|
*/
|
||||||
function __construct($record = null, $isSingleton = false, $model = null) {
|
function __construct($record = null, $isSingleton = false, $model = null) {
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
// Set the fields data.
|
// Set the fields data.
|
||||||
if(!$record) {
|
if(!$record) {
|
||||||
$record = array(
|
$record = array(
|
||||||
@ -345,8 +348,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
HTTP::register_modification_date($record['LastEdited']);
|
HTTP::register_modification_date($record['LastEdited']);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
// Must be called after parent constructor
|
// Must be called after parent constructor
|
||||||
if(!$isSingleton && (!isset($this->record['ID']) || !$this->record['ID'])) {
|
if(!$isSingleton && (!isset($this->record['ID']) || !$this->record['ID'])) {
|
||||||
$this->populateDefaults();
|
$this->populateDefaults();
|
||||||
|
Loading…
Reference in New Issue
Block a user