Skip to content
This repository
Browse code

MINOR Removed usage of deprecated Object::uninherited_static() in cor…

…e, improves CMS loading speed in live mode by ~3.5%
  • Loading branch information...
commit c73b80049a8485cfe4883ad1c87042f60219cf99 1 parent 0fd7ce6
Ingo Schommer authored April 12, 2012
37  model/DataObject.php
@@ -208,7 +208,7 @@ public static function database_fields($class) {
208 208
 	 * @return array Map of fieldname to specification, similiar to {@link DataObject::$db}.
209 209
 	 */
210 210
 	public static function custom_database_fields($class) {
211  
-		$fields = Object::uninherited_static($class, 'db');
  211
+		$fields = Config::inst()->get($class, 'db', Config::UNINHERITED);
212 212
 		
213 213
 		foreach(self::composite_fields($class, false) as $fieldName => $fieldClass) {
214 214
 			// Remove the original fieldname, its not an actual database column
@@ -222,7 +222,7 @@ public static function custom_database_fields($class) {
222 222
 		}
223 223
 		
224 224
 		// Add has_one relationships
225  
-		$hasOne = Object::uninherited_static($class, 'has_one');
  225
+		$hasOne = Config::inst()->get($class, 'has_one', Config::UNINHERITED);
226 226
 		if($hasOne) foreach(array_keys($hasOne) as $field) {
227 227
 			$fields[$field . 'ID'] = 'ForeignKey';
228 228
 		}
@@ -268,7 +268,7 @@ static function composite_fields($class, $aggregated = true) {
268 268
 	private static function cache_composite_fields($class) {
269 269
 		$compositeFields = array();
270 270
 		
271  
-		$fields = Object::uninherited_static($class, 'db');
  271
+		$fields = Config::inst()->get($class, 'db', Config::UNINHERITED);
272 272
 		if($fields) foreach($fields as $fieldName => $fieldClass) {
273 273
 			// Strip off any parameters
274 274
 			$bPos = strpos('(', $fieldClass);
@@ -954,7 +954,7 @@ public function populateDefaults() {
954 954
 		$classes = array_reverse(ClassInfo::ancestry($this));
955 955
 		
956 956
 		foreach($classes as $class) {
957  
-			$defaults = Object::uninherited_static($class, 'defaults');
  957
+			$defaults = Config::inst()->get($class, 'defaults', Config::UNINHERITED);
958 958
 			
959 959
 			if($defaults && !is_array($defaults)) {
960 960
 				user_error("Bad '$this->class' defaults given: " . var_export($defaults, true),
@@ -1417,13 +1417,13 @@ public function has_one($component = null) {
1417 1417
 			if(in_array($class, array('Object', 'ViewableData', 'DataObject'))) continue;
1418 1418
 
1419 1419
 			if($component) {
1420  
-				$hasOne = Object::uninherited_static($class, 'has_one');
  1420
+				$hasOne = Config::inst()->get($class, 'has_one', Config::UNINHERITED);
1421 1421
 				
1422 1422
 				if(isset($hasOne[$component])) {
1423 1423
 					return $hasOne[$component];
1424 1424
 				}
1425 1425
 			} else {
1426  
-				$newItems = (array) Object::uninherited_static($class, 'has_one');
  1426
+				$newItems = (array)Config::inst()->get($class, 'has_one', Config::UNINHERITED);
1427 1427
 				// Validate the data
1428 1428
 				foreach($newItems as $k => $v) {
1429 1429
 					if(!is_string($k) || is_numeric($k) || !is_string($v)) user_error("$class::\$has_one has a bad entry: " 
@@ -1484,13 +1484,13 @@ public function db($fieldName = null) {
1484 1484
 			}
1485 1485
 
1486 1486
 			if($fieldName) {
1487  
-				$db = Object::uninherited_static($class, 'db');
  1487
+				$db = Config::inst()->get($class, 'db', Config::UNINHERITED);
1488 1488
 				
1489 1489
 				if(isset($db[$fieldName])) {
1490 1490
 					return $db[$fieldName];
1491 1491
 				}
1492 1492
 			} else {
1493  
-				$newItems = (array) Object::uninherited_static($class, 'db');
  1493
+				$newItems = (array)Config::inst()->get($class, 'db', Config::UNINHERITED);
1494 1494
 				// Validate the data
1495 1495
 				foreach($newItems as $k => $v) {
1496 1496
 					if(!is_string($k) || is_numeric($k) || !is_string($v)) user_error("$class::\$db has a bad entry: " 
@@ -1635,7 +1635,7 @@ public function many_many($component = null) {
1635 1635
 			if(in_array($class, array('ViewableData', 'Object', 'DataObject'))) continue;
1636 1636
 
1637 1637
 			if($component) {
1638  
-				$manyMany = Object::uninherited_static($class, 'many_many');
  1638
+				$manyMany = Config::inst()->get($class, 'many_many', Config::UNINHERITED);
1639 1639
 				// Try many_many
1640 1640
 				$candidate = (isset($manyMany[$component])) ? $manyMany[$component] : null;
1641 1641
 				if($candidate) {
@@ -1645,13 +1645,13 @@ public function many_many($component = null) {
1645 1645
 				}
1646 1646
 
1647 1647
 				// Try belongs_many_many
1648  
-				$belongsManyMany = Object::uninherited_static($class, 'belongs_many_many');
  1648
+				$belongsManyMany = Config::inst()->get($class, 'belongs_many_many', Config::UNINHERITED);
1649 1649
 				$candidate = (isset($belongsManyMany[$component])) ? $belongsManyMany[$component] : null;
1650 1650
 				if($candidate) {
1651 1651
 					$childField = $candidate . "ID";
1652 1652
 
1653 1653
 					// We need to find the inverse component name
1654  
-					$otherManyMany = Object::uninherited_static($candidate, 'many_many');
  1654
+					$otherManyMany = Config::inst()->get($candidate, 'many_many', Config::UNINHERITED);
1655 1655
 					if(!$otherManyMany) {
1656 1656
 						user_error("Inverse component of $candidate not found ({$this->class})", E_USER_ERROR);
1657 1657
 					}
@@ -1670,7 +1670,7 @@ public function many_many($component = null) {
1670 1670
 					user_error("Orphaned \$belongs_many_many value for $this->class.$component", E_USER_ERROR);
1671 1671
 				}
1672 1672
 			} else {
1673  
-				$newItems = (array) Object::uninherited_static($class, 'many_many');
  1673
+				$newItems = (array)Config::inst()->get($class, 'many_many', Config::UNINHERITED);
1674 1674
 				// Validate the data
1675 1675
 				foreach($newItems as $k => $v) {
1676 1676
 					if(!is_string($k) || is_numeric($k) || !is_string($v)) user_error("$class::\$many_many has a bad entry: " 
@@ -1678,7 +1678,7 @@ public function many_many($component = null) {
1678 1678
 				}
1679 1679
 				$items = isset($items) ? array_merge($newItems, $items) : $newItems;
1680 1680
 				
1681  
-				$newItems = (array) Object::uninherited_static($class, 'belongs_many_many');
  1681
+				$newItems = (array)Config::inst()->get($class, 'belongs_many_many', Config::UNINHERITED);
1682 1682
 				// Validate the data
1683 1683
 				foreach($newItems as $k => $v) {
1684 1684
 					if(!is_string($k) || is_numeric($k) || !is_string($v)) user_error("$class::\$belongs_many_many has a bad entry: " 
@@ -1700,8 +1700,7 @@ public function many_many($component = null) {
1700 1700
 	 * @return array or false
1701 1701
 	 */
1702 1702
 	function database_extensions($class){
1703  
-		
1704  
-		$extensions = Object::uninherited_static($class, 'database_extensions');
  1703
+		$extensions = Config::inst()->get($class, 'database_extensions', Config::UNINHERITED);
1705 1704
 		
1706 1705
 		if($extensions)
1707 1706
 			return $extensions;
@@ -2126,7 +2125,7 @@ public function hasOwnTableDatabaseField($field) {
2126 2125
 		
2127 2126
 		// if no fieldmap is cached, get all fields
2128 2127
 		if(!$fieldMap) {
2129  
-			$fieldMap = Object::uninherited_static($this->class, 'db');
  2128
+			$fieldMap = Config::inst()->get($this->class, 'db', Config::UNINHERITED);
2130 2129
 			
2131 2130
 			// all $db fields on this specific class (no parents)
2132 2131
 			foreach(self::composite_fields($this->class, false) as $fieldname => $fieldtype) {
@@ -2138,7 +2137,7 @@ public function hasOwnTableDatabaseField($field) {
2138 2137
 			
2139 2138
 			// all has_one relations on this specific class,
2140 2139
 			// add foreign key
2141  
-			$hasOne = Object::uninherited_static($this->class, 'has_one');
  2140
+			$hasOne = Config::inst()->get($this->class, 'has_one', Config::UNINHERITED);
2142 2141
 			if($hasOne) foreach($hasOne as $fieldName => $fieldSchema) {
2143 2142
 				$fieldMap[$fieldName . 'ID'] = "ForeignKey";
2144 2143
 			}
@@ -2171,7 +2170,7 @@ public static function has_own_table($dataClass) {
2171 2170
 			if(get_parent_class($dataClass) == 'DataObject') {
2172 2171
 				DataObject::$cache_has_own_table[$dataClass] = true;
2173 2172
 			} else {
2174  
-				DataObject::$cache_has_own_table[$dataClass] = Object::uninherited_static($dataClass, 'db') || Object::uninherited_static($dataClass, 'has_one');
  2173
+				DataObject::$cache_has_own_table[$dataClass] = Config::inst()->get($dataClass, 'db', Config::UNINHERITED) || Config::inst()->get($dataClass, 'has_one', Config::UNINHERITED);
2175 2174
 			}
2176 2175
 		}
2177 2176
 		return DataObject::$cache_has_own_table[$dataClass];
@@ -2967,7 +2966,7 @@ public function fieldLabels($includerelations = true) {
2967 2966
 		if($ancestry) foreach($ancestry as $ancestorClass) {
2968 2967
 			if($ancestorClass == 'ViewableData') break;
2969 2968
 			$types = array(
2970  
-				'db'        => (array) Object::uninherited_static($ancestorClass, 'db'),
  2969
+				'db'        => (array)Config::inst()->get($ancestorClass, 'db', Config::UNINHERITED)
2971 2970
 			);
2972 2971
 			if($includerelations){
2973 2972
 				$types['has_one'] = (array)singleton($ancestorClass)->uninherited('has_one', true);
3  view/ViewableData.php
@@ -292,8 +292,7 @@ public function buildCastingCache(&$cache) {
292 292
 				$mergeFields = is_subclass_of($class, 'DataObject') ? array('db', 'casting') : array('casting');
293 293
 				
294 294
 				if($mergeFields) foreach($mergeFields as $field) {
295  
-					$casting = Object::uninherited_static($class, $field);
296  
-					
  295
+					$casting = Config::inst()->get($class, $field, Config::UNINHERITED);
297 296
 					if($casting) foreach($casting as $field => $cast) {
298 297
 						if(!isset($cache[$field])) $cache[$field] = self::castingObjectCreatorPair($cast);
299 298
 					}

0 notes on commit c73b800

Please sign in to comment.
Something went wrong with that request. Please try again.