View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
04898Bug reportsOtherpublic2011-02-17 18:25
Reporterjacopo Assigned Totexens  
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.91RC2 
Target Version1.91RC4Fixed in Version1.91RC4 
Summary04898: Cannot delete individual answers [PATCH]
Description

When I try to delete an individual answer to a survey, I get a SQL error (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM lime_survey_99822 where id=44' at line 1:SELECT FROM lime_survey_99822 where id=44)

I believe the bug lies around line 370 in browse.php: I think the script should also check if $fuqtquestions is empty or not.

I attach a patch against the latest SVN (9712).

Steps To Reproduce
  1. Create a survey (I have tried with a non-anonymous one)
  2. Browse the list of recent responses
  3. Try to delete one by clicking on the "X" on its row
TagsNo tags attached.
Attached Files
patch-deleteanswer.patch (1,824 bytes)   
Index: admin/browse.php
===================================================================
--- admin/browse.php	(revision 9712)
+++ admin/browse.php	(working copy)
@@ -367,19 +367,21 @@
                 $fuqtquestions[] = $field['fieldname'];
         }
 
-        // find all responses (filenames) to the fuqt questions
-        $query="SELECT " . implode(", ", $fuqtquestions) . " FROM $surveytable where id={$_POST['deleteanswer']}";
-        $responses = db_execute_assoc($query) or safe_die("Could not fetch responses<br />$query<br />".$connect->ErrorMsg());
+        if (!empty($fuqtquestions)) {
+            // find all responses (filenames) to the fuqt questions
+            $query="SELECT " . implode(", ", $fuqtquestions) . " FROM $surveytable where id={$_POST['deleteanswer']}";
+            $responses = db_execute_assoc($query) or safe_die("Could not fetch responses<br />$query<br />".$connect->ErrorMsg());
 
-        while($json = $responses->FetchRow())
-        {
-            foreach ($fuqtquestions as $fieldname)
+            while($json = $responses->FetchRow())
             {
-                $phparray = json_decode($json[$fieldname]);
-                foreach($phparray as $metadata)
+                foreach ($fuqtquestions as $fieldname)
                 {
-                    $path = dirname(getcwd())."/upload/surveys/".$surveyid."/files/";
-                    unlink($path.$metadata->filename); // delete the file
+		     $phparray = json_decode($json[$fieldname]);
+                     foreach($phparray as $metadata)
+                     {
+                          $path = dirname(getcwd())."/upload/surveys/".$surveyid."/files/";
+                          unlink($path.$metadata->filename); // delete the file
+                     }
                 }
             }
         }
patch-deleteanswer.patch (1,824 bytes)   
Bug heat4
Complete LimeSurvey version number (& build)9712
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL 5.1.49
Server OS (if known)Ubuntu 10.10
Webserver software & version (if known)Apache 2.2.16
PHP Version5.3.3

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2011-01-26 23:40

administrator   ~13986

Texens, please verify the patch and apply it accrodingly because the issue is caused by FUQT code. Thank you!

texens

texens

2011-02-03 16:36

reporter   ~14048

Fixed in r9741.
Thanks jacopo for the patch :)

c_schmitz

c_schmitz

2011-02-17 18:25

administrator   ~14236

1.91RC4 released

Issue History

Date Modified Username Field Change
2011-01-24 15:05 jacopo New Issue
2011-01-24 15:05 jacopo File Added: patch-deleteanswer.patch
2011-01-26 23:39 c_schmitz Assigned To => texens
2011-01-26 23:39 c_schmitz Status new => assigned
2011-01-26 23:40 c_schmitz Note Added: 13986
2011-02-01 16:15 mdekker Target Version => 1.91RC4
2011-02-03 16:36 texens Note Added: 14048
2011-02-03 16:36 texens Status assigned => resolved
2011-02-03 16:36 texens Fixed in Version => 1.91RC4
2011-02-03 16:36 texens Resolution open => fixed
2011-02-17 18:25 c_schmitz Note Added: 14236
2011-02-17 18:25 c_schmitz Status resolved => closed