mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENH Cache DataObject::getSchema()
This commit is contained in:
parent
0c40cc9b3d
commit
46d7930489
@ -329,6 +329,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
private static $cascade_duplicates = [];
|
private static $cascade_duplicates = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to cache the schema to prevent repeatedly fetching the singleton
|
||||||
|
* While this is a fast operation, in some scenarios getSchema() is called an extremely large number of times
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
private static ?DataObjectSchema $schema = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get schema object
|
* Get schema object
|
||||||
*
|
*
|
||||||
@ -336,7 +344,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
public static function getSchema()
|
public static function getSchema()
|
||||||
{
|
{
|
||||||
return Injector::inst()->get(DataObjectSchema::class);
|
if (is_null(self::$schema)) {
|
||||||
|
self::$schema = Injector::inst()->get(DataObjectSchema::class);
|
||||||
|
}
|
||||||
|
return self::$schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user