mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Passing $cache parameter from DataObject:.get_by_id() to DataObject::get_one()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77896 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
7bef503953
commit
30165bd1da
@ -2603,19 +2603,20 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*
|
*
|
||||||
* @param string $callerClass The class of the object to be returned
|
* @param string $callerClass The class of the object to be returned
|
||||||
* @param int $id The id of the element
|
* @param int $id The id of the element
|
||||||
|
* @param boolean $cache See {@link get_one()}
|
||||||
*
|
*
|
||||||
* @return DataObject The element
|
* @return DataObject The element
|
||||||
*/
|
*/
|
||||||
public static function get_by_id($callerClass, $id) {
|
public static function get_by_id($callerClass, $id, $cache = true) {
|
||||||
if(is_numeric($id)) {
|
if(is_numeric($id)) {
|
||||||
if(is_subclass_of($callerClass, 'DataObject')) {
|
if(is_subclass_of($callerClass, 'DataObject')) {
|
||||||
$tableClasses = ClassInfo::dataClassesFor($callerClass);
|
$tableClasses = ClassInfo::dataClassesFor($callerClass);
|
||||||
$baseClass = array_shift($tableClasses);
|
$baseClass = array_shift($tableClasses);
|
||||||
return DataObject::get_one($callerClass,"\"$baseClass\".\"ID\" = $id");
|
return DataObject::get_one($callerClass,"\"$baseClass\".\"ID\" = $id", $cache);
|
||||||
|
|
||||||
// This simpler code will be used by non-DataObject classes that implement DataObjectInterface
|
// This simpler code will be used by non-DataObject classes that implement DataObjectInterface
|
||||||
} else {
|
} else {
|
||||||
return DataObject::get_one($callerClass,"\"ID\" = $id");
|
return DataObject::get_one($callerClass,"\"ID\" = $id", $cache);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
user_error("DataObject::get_by_id passed a non-numeric ID #$id", E_USER_WARNING);
|
user_error("DataObject::get_by_id passed a non-numeric ID #$id", E_USER_WARNING);
|
||||||
|
Loading…
Reference in New Issue
Block a user