From 42aef0105d2d7b90aebc19e7ea92b92d78a6af1d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 8 Oct 2016 19:34:59 +0000 Subject: [PATCH] DbObject: exists() should respect prefetch... ...also for negative lookups refs #12876 --- library/Director/Data/Db/DbObject.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php index 5a5a9496..44e4d45a 100644 --- a/library/Director/Data/Db/DbObject.php +++ b/library/Director/Data/Db/DbObject.php @@ -933,6 +933,12 @@ abstract class DbObject return $obj; } + protected static function classWasPrefetched() + { + $class = get_called_class(); + return array_key_exists($class, self::$prefetched); + } + protected static function getPrefetched($key) { $class = get_called_class(); @@ -951,8 +957,6 @@ abstract class DbObject protected static function hasPrefetched($key) { - // TODO: temporarily disabled as of collisions with services - //return false; $class = get_called_class(); if (! array_key_exists($class, self::$prefetchStats)) { self::$prefetchStats[$class] = (object) array( @@ -1088,6 +1092,8 @@ abstract class DbObject { if (static::getPrefetched($id)) { return true; + } elseif (static::classWasPrefetched()) { + return false; } $class = get_called_class();