diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 116261a47..476df9d1b 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -714,11 +714,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity foreach($classes as $class) { $defaults = Object::get_static($class, 'defaults'); + if($defaults) foreach($defaults as $fieldName => $fieldValue) { // SRM 2007-03-06: Stricter check if(!isset($this->$fieldName) || $this->$fieldName === null) { $this->$fieldName = $fieldValue; - } // Set many-many defaults with an array of ids if(is_array($fieldValue) && $this->many_many($fieldName)) { @@ -836,6 +836,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if(isset($ancestry) && is_array($ancestry)) { foreach($ancestry as $idx => $class) { $classSingleton = singleton($class); + foreach($this->record as $fieldName => $fieldValue) { if(isset($this->changed[$fieldName]) && $this->changed[$fieldName] && $fieldType = $classSingleton->hasOwnTableDatabaseField($fieldName)) { $fieldObj = $this->dbObject($fieldName); @@ -3147,4 +3148,4 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } -?> +?> \ No newline at end of file diff --git a/core/model/Database.php b/core/model/Database.php index 77489b0ad..04f84453c 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -298,12 +298,13 @@ abstract class Database extends Object { if(!$newTable && !isset($this->indexList[$table])) { $this->indexList[$table] = $this->indexList($table); } - - $index_alt=DB::getConn()->modifyIndex($index); - + //Fix up the index for database purposes $index=DB::getConn()->getDbSqlDefinition($table, $index, null, true); + //Fix the key for database purposes + $index_alt=DB::getConn()->modifyIndex($index, $spec); + if(!$newTable) { if(is_array($this->indexList[$table][$index_alt])) { $array_spec = $this->indexList[$table][$index_alt]['spec'];