BUGFIX: Ensure that statics are updated by decorators before static variables are interrogated by static methods.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77823 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-05-26 03:25:51 +00:00
parent 60c5570bf8
commit ccb4916d19
1 changed files with 6 additions and 3 deletions

View File

@ -185,6 +185,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return array
*/
public static function custom_database_fields($class) {
// Ensure that statics are loaded from the decorators
singleton($class);
$fields = Object::uninherited_static($class, 'db');
$hasOne = Object::uninherited_static($class, 'has_one');
@ -911,7 +914,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
if(isset($isNewRecord) && $isNewRecord && isset($manipulation[$baseTable])) {
$manipulation[$baseTable]['command'] = 'update';
}
DB::manipulate($manipulation);
if(isset($isNewRecord) && $isNewRecord) {
@ -2029,10 +2031,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return bool
*/
public function has_own_table($dataClass) {
// The condition below has the same effect as !is_subclass_of($dataClass,'DataObject'),
// which causes PHP < 5.3 to segfault in rare circumstances, see PHP bug #46753
if($dataClass == 'DataObject' || !in_array('DataObject', ClassInfo::ancestry($dataClass))) return false;
// Ensure that statics are loaded from the decorators
singleton($dataClass);
if(!isset(self::$cache_has_own_table[$dataClass])) {
if(get_parent_class($dataClass) == 'DataObject') {
@ -2555,7 +2559,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
}
$this->extend('augmentSQL', $query);
$records = $query->execute();
$records->rewind();
$record = $records->current();