Kaynağa Gözat

Internal: fixed the caching of DBObject::ToArgs()
1) Wasn't reset when the object was written the DB (thus having its ID set)
2) Wasn't taking the argument name into account (the list of placeholders was defined by the first caller)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3491 a333f486-631f-4898-b8df-5754b55c2be0

romainq 10 yıl önce
ebeveyn
işleme
e8ba1bf791
1 değiştirilmiş dosya ile 10 ekleme ve 3 silme
  1. 10 3
      core/dbobject.class.php

+ 10 - 3
core/dbobject.class.php

@@ -844,6 +844,8 @@ abstract class DBObject implements iDisplay
 			throw new CoreException("Changing the key ({$this->m_iKey} to $iNewKey) on an object (class {".get_class($this).") wich already exists in the Database");
 		}
 		$this->m_iKey = $iNewKey;
+		// Invalidate the argument cache
+		$this->m_aAsArgs = null;
 	}
 	/**
 	 * Get the icon representing this object
@@ -1488,6 +1490,8 @@ abstract class DBObject implements iDisplay
 		{
 			// Take the autonumber
 			$this->m_iKey = $iNewKey;
+			// Invalidate the argument cache
+			$this->m_aAsArgs = null;
 		}
 		return $this->m_iKey;
 	}
@@ -2291,6 +2295,10 @@ abstract class DBObject implements iDisplay
 	{
 		if (is_null($this->m_aAsArgs))
 		{
+			$this->m_aAsArgs = array();
+		}
+		if (!array_key_exists($sArgName, $this->m_aAsArgs))
+		{
 			$oKPI = new ExecutionKPI();
 			$aScalarArgs = $this->ToArgsForQuery($sArgName);
 			$aScalarArgs[$sArgName] = $this->GetKey();
@@ -2343,11 +2351,10 @@ abstract class DBObject implements iDisplay
 					$aScalarArgs[$sArgName.'->html('.$sAttCode.')'] = '<ul><li>'.implode("</li><li>", $aNames).'</li></ul>';
 				}
 			}
-
-			$this->m_aAsArgs = $aScalarArgs;
+			$this->m_aAsArgs[$sArgName] = $aScalarArgs;
 			$oKPI->ComputeStats('ToArgs', get_class($this));
 		}
-		return $this->m_aAsArgs;
+		return $this->m_aAsArgs[$sArgName];
 	}
 
 	// To be optionaly overloaded