mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Improved performance of DataObject::get_by_id() by setting order to "1" in the contained get_one() call
This commit is contained in:
parent
0920b0fcd9
commit
5755c27c30
@ -2963,13 +2963,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
public static function get_by_id($callerClass, $id, $cache = true) {
|
||||
if(is_numeric($id)) {
|
||||
if(is_subclass_of($callerClass, 'DataObject')) {
|
||||
$tableClasses = ClassInfo::dataClassesFor($callerClass);
|
||||
$baseClass = array_shift($tableClasses);
|
||||
return DataObject::get_one($callerClass,"\"$baseClass\".\"ID\" = $id", $cache);
|
||||
$baseClass = ClassInfo::baseDataClass($callerClass);
|
||||
return DataObject::get_one($callerClass,"\"$baseClass\".\"ID\" = $id", $cache, 1);
|
||||
|
||||
// This simpler code will be used by non-DataObject classes that implement DataObjectInterface
|
||||
} else {
|
||||
return DataObject::get_one($callerClass,"\"ID\" = $id", $cache);
|
||||
return DataObject::get_one($callerClass,"\"ID\" = $id", $cache, 1);
|
||||
}
|
||||
} else {
|
||||
user_error("DataObject::get_by_id passed a non-numeric ID #$id", E_USER_WARNING);
|
||||
|
@ -557,7 +557,7 @@ class Member extends DataObject {
|
||||
static function currentUser() {
|
||||
$id = Member::currentUserID();
|
||||
if($id) {
|
||||
return DataObject::get_one("Member", "\"Member\".\"ID\" = $id");
|
||||
return DataObject::get_one("Member", "\"Member\".\"ID\" = $id", true, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user