[icinga-checkins] icinga.org: icingaweb2-module-director/master: DbObject: exists() should respect prefetch...

git at icinga.org git at icinga.org
Mon Oct 10 12:00:29 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 42aef0105d2d7b90aebc19e7ea92b92d78a6af1d
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=42aef0105d2d7b90aebc19e7ea92b92d78a6af1d

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sat Oct  8 19:34:59 2016 +0000

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 5a5a949..44e4d45 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();



More information about the icinga-checkins mailing list