mlanthaler: Bugfix: Added needed checks if the $ancestry variable is set respectively if it is an array.

(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42140 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-16 16:40:57 +00:00
parent 23b88e60f6
commit 0edcb97d57

View File

@ -408,7 +408,8 @@ class DataObject extends Controller {
}
foreach($this->getClassAncestry() as $ancestor) {
if(ClassInfo::hasTable($ancestor)) $ancestry[] = $ancestor;
if(ClassInfo::hasTable($ancestor))
$ancestry[] = $ancestor;
}
// Look for some changes to make
@ -426,7 +427,7 @@ class DataObject extends Controller {
// New records have their insert into the base data table done first, so that they can pass the
// generated primary key on to the rest of the manipulation
if(!$this->record['ID']) {
if(!$this->record['ID'] && isset($ancestry[0])) {
$baseTable = $ancestry[0];
DB::query("INSERT INTO `{$baseTable}` SET Created = NOW()");
@ -437,6 +438,7 @@ class DataObject extends Controller {
}
// Divvy up field saving into a number of database manipulations
if(is_array($ancestry)) {
foreach($ancestry as $idx => $class) {
$classSingleton = singleton($class);
foreach($this->record as $fieldName => $value) {
@ -463,6 +465,7 @@ class DataObject extends Controller {
unset($manipulation[$class]);
}
}
}
$this->extend('augmentWrite', $manipulation);
@ -502,6 +505,7 @@ class DataObject extends Controller {
return $this->record['ID'];
}
/**
* Perform a write without affecting the version table.
* On objects without versioning.
@ -1765,4 +1769,6 @@ class DataObject extends Controller {
*/
public static $default_sort = null;
}
?>