From a74129b5a63e5a70a21bf466a9e40fde82ed0d8c Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 11 Aug 2009 08:57:14 +0000 Subject: [PATCH] ENHANCEMENT: Improved performance of DataObject::hasField() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84165 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index ccb646d9f..a687548f8 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -2096,7 +2096,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity return ( array_key_exists($field, $this->record) || $this->hasDatabaseField($field) - || array_key_exists($field, $this->db()) || $this->hasMethod("get{$field}") ); } @@ -2110,13 +2109,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity */ public function hasDatabaseField($field) { // Add base fields which are not defined in static $db - $fixedFields = array( + static $fixedFields = array( 'ID' => 'Int', 'ClassName' => 'Enum', 'LastEdited' => 'SSDatetime', 'Created' => 'SSDatetime', - // Add fields from Versioned decorator - 'Version' => $this->hasExtension('Versioned') ? 'Int' : false, ); if(isset($fixedFields[$field])) return true; @@ -2130,8 +2127,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * * @param string $field Name of the field * @return string The field type of the given field - */ - public function hasOwnTableDatabaseField($field) { + */ public function hasOwnTableDatabaseField($field) { // Add base fields which are not defined in static $db if($field == "ID") return "Int"; if($field == "ClassName" && get_parent_class($this) == "DataObject") return "Enum";