mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Remove redundant gc_collect_cycles()
Cleanup dead references to DataObject::$destroyed Fixes #7326
This commit is contained in:
parent
9fb5a2a693
commit
45998444d7
@ -2035,6 +2035,7 @@ The below methods have been added or had their functionality updated to `DBDate`
|
|||||||
* `DataObject::has_own_table` renamed and moved to `DataObjectSchema::classHasTable`
|
* `DataObject::has_own_table` renamed and moved to `DataObjectSchema::classHasTable`
|
||||||
* `DataObject::composite_fields` renamed and moved to `DataObjectSchema::compositeFields``
|
* `DataObject::composite_fields` renamed and moved to `DataObjectSchema::compositeFields``
|
||||||
* `DataObject::manyManyExtraFieldsForComponent` moved to `DataObjectSchema`
|
* `DataObject::manyManyExtraFieldsForComponent` moved to `DataObjectSchema`
|
||||||
|
* `DataObject::$destroyed` is now deprecated
|
||||||
* Removed `DataObject::validateModelDefinitions`. Relations are now validated within `DataObjectSchema`
|
* Removed `DataObject::validateModelDefinitions`. Relations are now validated within `DataObjectSchema`
|
||||||
* Removed `DataObject` methods `hasOwnTableDatabaseField`, `has_own_table_database_field` and
|
* Removed `DataObject` methods `hasOwnTableDatabaseField`, `has_own_table_database_field` and
|
||||||
`hasDatabaseFields` are superceded by `DataObjectSchema::fieldSpec`.
|
`hasDatabaseFields` are superceded by `DataObjectSchema::fieldSpec`.
|
||||||
|
@ -61,9 +61,11 @@ trait CustomMethods
|
|||||||
return $config['callback']($this, $arguments);
|
return $config['callback']($this, $arguments);
|
||||||
}
|
}
|
||||||
case isset($config['property']) : {
|
case isset($config['property']) : {
|
||||||
$obj = $config['index'] !== null ?
|
$property = $config['property'];
|
||||||
$this->{$config['property']}[$config['index']] :
|
$index = $config['index'];
|
||||||
$this->{$config['property']};
|
$obj = $index !== null ?
|
||||||
|
$this->{$property}[$index] :
|
||||||
|
$this->{$property};
|
||||||
|
|
||||||
if ($obj) {
|
if ($obj) {
|
||||||
if (!empty($config['callSetOwnerFirst'])) {
|
if (!empty($config['callSetOwnerFirst'])) {
|
||||||
@ -78,16 +80,10 @@ trait CustomMethods
|
|||||||
return $retVal;
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->destroyed)) {
|
throw new BadMethodCallException(
|
||||||
throw new BadMethodCallException(
|
"Object->__call(): {$class} cannot pass control to {$property}({$index})."
|
||||||
"Object->__call(): attempt to call $method on a destroyed $class object"
|
. ' Perhaps this object was mistakenly destroyed?'
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
throw new BadMethodCallException(
|
|
||||||
"Object->__call(): $class cannot pass control to $config[property]($config[index])."
|
|
||||||
. ' Perhaps this object was mistakenly destroyed?'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case isset($config['wrap']): {
|
case isset($config['wrap']): {
|
||||||
array_unshift($arguments, $config['method']);
|
array_unshift($arguments, $config['method']);
|
||||||
|
@ -137,8 +137,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
private static $default_classname = null;
|
private static $default_classname = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if this DataObject has been destroyed.
|
* @deprecated 4.0..5.0
|
||||||
* @var boolean
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $destroyed = false;
|
public $destroyed = false;
|
||||||
|
|
||||||
@ -386,8 +386,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
public function destroy()
|
public function destroy()
|
||||||
{
|
{
|
||||||
//$this->destroyed = true;
|
|
||||||
gc_collect_cycles();
|
|
||||||
$this->flushCache(false);
|
$this->flushCache(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2868,12 +2866,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$cacheComponents = array($filter, $orderby, $SNG->extend('cacheKeyComponent'));
|
$cacheComponents = array($filter, $orderby, $SNG->extend('cacheKeyComponent'));
|
||||||
$cacheKey = md5(var_export($cacheComponents, true));
|
$cacheKey = md5(var_export($cacheComponents, true));
|
||||||
|
|
||||||
// Flush destroyed items out of the cache
|
|
||||||
if ($cache && isset(self::$_cache_get_one[$callerClass][$cacheKey])
|
|
||||||
&& self::$_cache_get_one[$callerClass][$cacheKey] instanceof DataObject
|
|
||||||
&& self::$_cache_get_one[$callerClass][$cacheKey]->destroyed) {
|
|
||||||
self::$_cache_get_one[$callerClass][$cacheKey] = false;
|
|
||||||
}
|
|
||||||
$item = null;
|
$item = null;
|
||||||
if (!$cache || !isset(self::$_cache_get_one[$callerClass][$cacheKey])) {
|
if (!$cache || !isset(self::$_cache_get_one[$callerClass][$cacheKey])) {
|
||||||
$dl = DataObject::get($callerClass)->where($filter)->sort($orderby);
|
$dl = DataObject::get($callerClass)->where($filter)->sort($orderby);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user