Fix caching in DataObject::get_one()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47748 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-01-09 02:26:12 +00:00
parent 9ab3d5e646
commit 4dd628c9d0

View File

@ -1505,7 +1505,7 @@ class DataObject extends Controller implements DataObjectInterface {
* @return DataObject The first item matching the query * @return DataObject The first item matching the query
*/ */
public static function get_one($callerClass, $filter = "", $cache = true, $orderby = "") { public static function get_one($callerClass, $filter = "", $cache = true, $orderby = "") {
if(!$cache || !isset(DataObject::$cache_get_one[$callerClass][$filter]) || isset(DataObject::$cache_get_one[$callerClass][$filter]->destroyed)) { if(!$cache || !isset(DataObject::$cache_get_one[$callerClass][$filter]) || DataObject::$cache_get_one[$callerClass][$filter]->destroyed) {
$item = singleton($callerClass)->instance_get_one($filter, $orderby); $item = singleton($callerClass)->instance_get_one($filter, $orderby);
if($cache) { if($cache) {
DataObject::$cache_get_one[$callerClass][$filter] = $item; DataObject::$cache_get_one[$callerClass][$filter] = $item;