]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Fix *all* unfreed results in unit tests - this was a hard task, but worth it
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sun, 25 Oct 2009 15:42:09 +0000 (15:42 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sun, 25 Oct 2009 15:42:09 +0000 (15:42 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@414 b3834d28-1941-0410-a4f8-b48e95affb8f

src/SemanticScuttle/Service/CommonDescription.php
src/SemanticScuttle/Service/Tag.php
src/SemanticScuttle/Service/Tag2Tag.php
src/SemanticScuttle/Service/TagCache.php
src/SemanticScuttle/Service/TagStat.php

index 75a67c011497334cc131f51d3e99bdfc28334ebe..c17e7e468c8e669853e8416a01fb6b101cd06233 100644 (file)
@@ -55,8 +55,9 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
             return false;
         }
 
-        if ($row =& $this->db->sql_fetchrow($dbresult)) {
-            $this->db->sql_freeresult($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)) {
-            $this->db->sql_freeresult($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){
index 93cfd458bc9a66b1296a6f0532c421bd87650966..e5393a1a79329e37c60c957d411cceaa804af133 100644 (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) {
index cc8abb8db5af61255ea3766b8f9328f7e3e8e1aa..dcbcf2eacbab60b260808d3f67e10b481c36aeae 100644 (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) {
index 9e8b29898d11914747186bf9032ae5f2b2dd8dc0..7908ae36088bfe5fe5ec261a41051c7a89bf873b 100644 (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;
 
index f925bfc8221797e728e1c3aff2a4c8c4ffa914c5..642a83caddced9762ac324863cb5b4f20f0c4c60 100644 (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) {