Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 890f7e3919c819cf0ef9dbd61649b43dcae43faa 1 parent ea910a5
Hamish Friedlander hafriedlander authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 model/DataObject.php
5 model/DataObject.php
View
@@ -295,6 +295,9 @@ private static function cache_composite_fields($class) {
* 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 @@ function __construct($record = null, $isSingleton = false, $model = null) {
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();
Please sign in to comment.
Something went wrong with that request. Please try again.