Alexander Nicolaysen Sørnes : bug: Move duplicate detection to a separate function

Alexander Nicolaysen Sørnes asornes at winehq.org
Thu Jul 30 09:53:08 CDT 2009


Module: appdb
Branch: master
Commit: 8e9122b6f5ae4cb35359b0569fdf96ae674e0692
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=8e9122b6f5ae4cb35359b0569fdf96ae674e0692

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Thu Jul 30 16:52:42 2009 +0200

bug: Move duplicate detection to a separate function

---

 include/bugs.php |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/include/bugs.php b/include/bugs.php
index ed22aaf..9c38fa8 100644
--- a/include/bugs.php
+++ b/include/bugs.php
@@ -106,21 +106,11 @@ class Bug
             return false;
         }
 
-        /* Check for Duplicates */
-
-        $sQuery = "SELECT *
-                   FROM buglinks 
-                   WHERE versionId = '?'";
-        if($hResult = query_parameters($sQuery, $this->iVersionId))
+        /* Check for duplicates */
+        if($this->isDuplicate())
         {
-            while($oRow = query_fetch_object($hResult))
-            {
-                if($oRow->bug_id == $this->iBug_id)
-                {
-                   addmsg("The Bug link has already been submitted.", "red");
-                   return false;
-                }
-            }
+           addmsg("The Bug link has already been submitted.", "red");
+           return false;
         }
 
         /* passed the checks so lets insert the puppy! */
@@ -204,6 +194,23 @@ class Bug
         return true;
     }
 
+    /* Checks whether the version already has a link for this bug */
+    public function isDuplicate()
+    {
+        $sQuery = "SELECT COUNT(linkId) as count
+                   FROM buglinks 
+                   WHERE versionId = '?'
+                   AND bug_id = '?'";
+        if($hResult = query_parameters($sQuery, $this->iVersionId, $this->iBug_id))
+        {
+            if(($oRow = query_fetch_object($hResult)))
+            {
+                return $oRow->count > 0;
+            }
+        }
+        return false;
+    }
+
     function mailSubmitter($bRejected=false)
     {
         global $aClean;




More information about the wine-cvs mailing list