Fix *all* unfreed results in unit tests - this was a hard task, but worth it

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@414 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
cweiske 2009-10-25 15:42:09 +00:00
parent 21db3ef6da
commit ae8ca8442e
5 changed files with 53 additions and 20 deletions

View file

@ -55,8 +55,9 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
return false;
}
if ($row =& $this->db->sql_fetchrow($dbresult)) {
$row = $this->db->sql_fetchrow($dbresult);
$this->db->sql_freeresult($dbresult);
if ($row) {
return $row;
} else {
return false;
@ -129,8 +130,9 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
return false;
}
if ($row =& $this->db->sql_fetchrow($dbresult)) {
$row = $this->db->sql_fetchrow($dbresult);
$this->db->sql_freeresult($dbresult);
if ($row) {
return $row;
} else {
return false;
@ -148,8 +150,9 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
return false;
}
return $this->db->sql_fetchrowset($dbresult);
$rowset = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $rowset;
}
function deleteDescriptionsForUser($uId){

View file

@ -34,7 +34,9 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
return false;
}
if ($row =& $this->db->sql_fetchrow($dbresult)) {
$row = $this->db->sql_fetchrow($dbresult);
$this->db->sql_freeresult($dbresult);
if ($row) {
return $row;
} else {
return array('tDescription'=>'');
@ -52,7 +54,9 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
return false;
}
if ($row =& $this->db->sql_fetchrow($dbresult)) {
$row = $this->db->sql_fetchrow($dbresult);
$this->db->sql_freeresult($dbresult);
if ($row) {
return true;
} else {
return false;
@ -69,7 +73,9 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService
return false;
}
return $this->db->sql_fetchrowset($dbresult);
$rowset = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $rowset;
}
function updateDescription($tag, $uId, $desc) {

View file

@ -39,7 +39,7 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$values = array('tag1' => $tag1, 'tag2' => $tag2, 'relationType'=> $relationType, 'uId'=> $uId);
$query = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
//die($query);
if (!($dbresult =& $this->db->sql_query($query))) {
if (!($dbresult = $this->db->sql_query($query))) {
$this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not attach tag to tag', '', __LINE__, __FILE__, $query, $this->db);
return false;
@ -280,7 +280,10 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
//echo($query."<br>\n");
return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
$dbres = $this->db->sql_query($query);
$hasTags = $this->db->sql_numrows($dbres) > 0;
$this->db->sql_freeresult($dbres);
return $hasTags;
}
function getLinks($uId) {
@ -290,7 +293,10 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
$query.= " AND uId = '".$uId."'";
}
return $this->db->sql_fetchrowset($this->db->sql_query($query));
$dbres = $this->db->sql_query($query);
$rowset = $this->db->sql_fetchrowset($dbres);
$this->db->sql_freeresult($dbres);
return $rowset;
}
function removeLinkedTags($tag1, $tag2, $relationType, $uId) {

View file

@ -121,8 +121,10 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
//echo($query."<br>\n");
return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
$dbres = $this->db->sql_query($query);
$rows = $this->db->sql_numrows($dbres);
$this->db->sql_freeresult($dbres);
return $rows > 0;
}
/*
@ -221,7 +223,10 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= " AND relationType = '='";
$query.= " AND uId = '".$uId."'";
return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
$dbres = $this->db->sql_query($query);
$rows = $this->db->sql_numrows($dbres);
$this->db->sql_freeresult($dbres);
return $rows > 0;
}
function _isSynonymValue($tag2, $uId) {
@ -233,7 +238,10 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$query.= " AND relationType = '='";
$query.= " AND uId = '".$uId."'";
return $this->db->sql_numrows($this->db->sql_query($query)) > 0;
$dbres = $this->db->sql_query($query);
$rows = $this->db->sql_numrows($dbres);
$this->db->sql_freeresult($dbres);
return $rows > 0;
}
function getSynonyms($tag1, $uId) {
@ -252,7 +260,7 @@ class SemanticScuttle_Service_TagCache extends SemanticScuttle_DbService
$tagservice =SemanticScuttle_Service_Factory::get('Tag');
$tag2 = $tagservice->normalize($tag2);
if($this->_isSynonymKey($tag2)) return $tag2;
if($this->_isSynonymKey($tag2, $uId)) return $tag2;
if($tag2 == '') return false;

View file

@ -30,7 +30,10 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$query.= " AND relationType = '". $relationType ."'";
$query.= " AND uId = '".$uId."'";
return $this->db->sql_numrows($this->db->sql_query($query));
$dbres = $this->db->sql_query($query);
$rows = $this->db->sql_numrows($dbres);
$this->db->sql_freeresult($dbres);
return $rows;
}
function getNbDescendants($tag1, $relationType, $uId) {
@ -41,6 +44,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$dbresults =& $this->db->sql_query($query);
$row = $this->db->sql_fetchrow($dbresults);
$this->db->sql_freeresult($dbresults);
if($row['nb'] == null) {
return 0;
} else {
@ -56,6 +60,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$dbresults =& $this->db->sql_query($query);
$row = $this->db->sql_fetchrow($dbresults);
$this->db->sql_freeresult($dbresults);
if($row['depth'] == null) {
return 0;
} else {
@ -71,6 +76,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$dbresults =& $this->db->sql_query($query);
$row = $this->db->sql_fetchrow($dbresults);
$this->db->sql_freeresult($dbresults);
if($row['nbupdate'] == null) {
return 0;
} else {
@ -84,7 +90,10 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$query.= " AND relationType = '". $relationType ."'";
$query.= " AND uId = '".$uId."'";
return $this->db->sql_numrows($this->db->sql_query($query))>0;
$dbres = $this->db->sql_query($query);
$rows = $this->db->sql_numrows($dbres);
$this->db->sql_freeresult($dbres);
return $rows > 0;
}
function createStat($tag1, $relationType, $uId) {
@ -136,6 +145,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
foreach($rowset as $row) {
$this->updateStat($row['tag1'], '>', $row['uId']);
}
$this->db->sql_freeresult($dbresult);
}
function setNbDescendants($tag1, $relationType, $uId, $nb) {
@ -147,7 +157,7 @@ class SemanticScuttle_Service_TagStat extends SemanticScuttle_DbService
$query.= " WHERE tag1 = '" .$tag1 ."'";
$query.= " AND relationType = '". $relationType ."'";
$query.= " AND uId = '".$uId."'";
$this->db->sql_query($query);
$this->db->sql_freeresult($this->db->sql_query($query));
}
function setMaxDepth($tag1, $relationType, $uId, $depth) {