瀏覽代碼

Fix for a warning about mysql_free() revealing a problem with DBObjectSet

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3257 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 11 年之前
父節點
當前提交
b6cefa790f
共有 2 個文件被更改,包括 13 次插入3 次删除
  1. 2 2
      core/dbobjectsearch.class.php
  2. 11 1
      core/dbobjectset.class.php

+ 2 - 2
core/dbobjectsearch.class.php

@@ -72,11 +72,11 @@ class DBObjectSearch
 	}
 
 	/**
-	 * Perform a deep clone (as opposed to "clone" which does copy a reference to the underlying objects
+	 * Perform a deep clone (as opposed to "clone" which does copy a reference to the underlying objects)
 	 **/	 	
 	public function DeepClone()
 	{
-		return unserialize(serialize($this));
+		return unserialize(serialize($this)); // Beware this serializes/unserializes the search and its parameters as well
 	}
 
 	public function AllowAllData() {$this->m_bAllowAllData = true;}

+ 11 - 1
core/dbobjectset.class.php

@@ -112,7 +112,17 @@ class DBObjectSet
 		$this->m_oSQLResult = null;
 	}
 
-
+	/**
+	 * Called when unserializing a DBObjectSet
+	 */
+	public function __wakeup()
+	{
+		$this->m_iNumTotalDBRows = null; // Total number of rows for the query without LIMIT. null if unknown yet
+		$this->m_iNumLoadedDBRows = 0; // Total number of rows LOADED in $this->m_oSQLResult via a SQL query. 0 by default
+		$this->m_bLoaded = false; // true when the filter has been used OR the set is built step by step (AddObject...)
+		$this->m_iCurrRow = 0;
+		$this->m_oSQLResult = null;
+	}
 	/**
 	 * Specify the subset of attributes to load (for each class of objects) before performing the SQL query for retrieving the rows from the DB
 	 *