From d72503b411ef560cb03c0478cc2d8dd8ace83f61 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 17 Dec 2012 12:42:14 +0000 Subject: [PATCH] Bug fix: (replicate what was done in the 1.2 branch) make sure that we differentiate the cache entries for the queries with and without the $bAllowAllData flag SVN:1.2.1[2581] --- core/metamodel.class.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/metamodel.class.php b/core/metamodel.class.php index c0e8404897..e4b23dca1c 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -4328,7 +4328,15 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass])) public static function MakeSingleRow($sClass, $iKey, $bMustBeFound = true, $bAllowAllData = false) { - if (!array_key_exists($sClass, self::$aQueryCacheGetObject)) + // Build the query cache signature + // + $sQuerySign = $sClass; + if($bAllowAllData) + { + $sQuerySign .= '_all_'; + } + + if (!array_key_exists($sQuerySign, self::$aQueryCacheGetObject)) { // NOTE: Quick and VERY dirty caching mechanism which relies on // the fact that the string '987654321' will never appear in the @@ -4343,13 +4351,13 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass])) } $sSQL = self::MakeSelectQuery($oFilter); - self::$aQueryCacheGetObject[$sClass] = $sSQL; - self::$aQueryCacheGetObjectHits[$sClass] = 0; + self::$aQueryCacheGetObject[$sQuerySign] = $sSQL; + self::$aQueryCacheGetObjectHits[$sQuerySign] = 0; } else { - $sSQL = self::$aQueryCacheGetObject[$sClass]; - self::$aQueryCacheGetObjectHits[$sClass] += 1; + $sSQL = self::$aQueryCacheGetObject[$sQuerySign]; + self::$aQueryCacheGetObjectHits[$sQuerySign] += 1; // echo " -load $sClass/$iKey- ".self::$aQueryCacheGetObjectHits[$sClass]."
\n"; } $sSQL = str_replace(CMDBSource::Quote(987654321), CMDBSource::Quote($iKey), $sSQL);