mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
23b88e60f6
commit
0edcb97d57
@ -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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user