View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
04270Bug reportsOtherpublic2010-07-12 17:20
Reporterelameno Assigned Toc_schmitz  
PriorityhighSeverityblock 
Status closedResolutionfixed 
Product Version1.87+ 
Summary04270: LSRC returns Internal Server Error when attempting to send reminder emails for a survey that has no reminders to send
Description

If the sSendEmail web service function is called to send 'remind' emails and all participants have already taken the survey, the function bombs with a SQL syntax error. It should return a value that indicates it didn't have anything to send.

I believe the crash also occurs if invitations have not yet been sent for the survey, but the patch I'm submitting should fix both error conditions.

Steps To Reproduce
  1. Setup a survey with a participant (or zero participants actually)
  2. Send invitations.
  3. Take the survey as the single participant.
  4. Attempt to send reminders via LSRC.
TagsNo tags attached.
Attached Files
sendReminder_fix.diff (2,927 bytes)   
Index: lsrc.helper.php
===================================================================
--- lsrc.helper.php	(revision 8570)
+++ lsrc.helper.php	(working copy)
@@ -354,23 +354,34 @@
                  * - if not: send reminders normally
                  */
                  
-                $remSQL = "SELECT tid, remindercount "
-                . "FROM ".db_table_name("tokens_{$surveyid}")." "
-                . "WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' "
-                . "ORDER BY remindercount desc LIMIT 1";
-                $remResult = db_execute_assoc($remSQL);
-                $remRow = $remResult->FetchRow();
+               	$remSQL = "SELECT tid, remindercount "
+			. "FROM ".db_table_name("tokens_{$surveyid}")." "
+			. "WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' "
+			. "ORDER BY remindercount desc LIMIT 1";
+
+		$this->debugLsrc("Executing SQL: ".$remSQL);
+
+		$remResult = db_execute_assoc($remSQL);
+		$remRow = $remResult->FetchRow();
+
+		/* Get the reminder count from the row, if we have a row.  If 
+		 * we don't have a row then we set reminderCount to 0 to prevent
+		 * queries down below from bombing out. */
+		$reminderCount = $remRow['remindercount'];
+		if(empty($reminderCount)) {
+			$this->debugLsrc("There are no reminders to send.");
+			$reminderCount = 0;
+		}
+			
+		$this->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.", remind ".$remRow['tid']."; ".$reminderCount." ");
+		
+		$sendOnlySQL = "SELECT tid, remindercount "
+		. "FROM ".db_table_name("tokens_{$surveyid}")." "
+		. "WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' AND remindercount < ".$reminderCount." "
+		. "ORDER BY tid asc LIMIT 1";
+
+		$this->debugLsrc("Executing SQL: ".$sendOnlySQL) 
                  
-                $this->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.", remind ".$remRow['tid']."; ".$remRow['remindercount']." ");
-                 
-                $sendOnlySQL = "SELECT tid, remindercount "
-                . "FROM ".db_table_name("tokens_{$surveyid}")." "
-                . "WHERE (completed = 'N' or completed = '') AND sent <> 'N' and sent <>'' AND token <>'' AND EMAIL <>'' AND remindercount < ".$remRow['remindercount']." "
-                . "ORDER BY tid asc LIMIT 1";
-                $sendOnlyResult = db_execute_assoc($sendOnlySQL);
-                 
-                 
-                 
                 if($sendOnlyResult->RecordCount()>0)
                 {
                     $sendOnlyRow = $sendOnlyResult->FetchRow();
@@ -4346,4 +4357,4 @@
         }
         return "".$iCountParticipants."Datasets given, ".$iInsertedParticipants." rows inserted. ";
     }
-}
\ No newline at end of file
+}
sendReminder_fix.diff (2,927 bytes)   
lsrc.helper.php (218,139 bytes)
Bug heat4
Complete LimeSurvey version number (& build)8411
I will donate to the project if issue is resolved
BrowserFirefox 3.6.3
Database type & versionMySQL 5
Server OS (if known)Fedora 10
Webserver software & version (if known)Apache 2.2
PHP Version5.2.9

Users monitoring this issue

There are no users monitoring this issue.

Activities

elameno

elameno

2010-04-08 18:09

reporter   ~11601

I've attached the changes in both a diff format and the full lsrc.helper.php file updated from the latest stable release.

c_schmitz

c_schmitz

2010-07-05 17:47

administrator   ~12355

Thank you very much for the patch. It will be resolved in 1.90RC2.
I am sorry that it took so long to merge this patch.

It looks like Tim (rakete) is very busy currently. Elameno, would you be interested to join the team and help fixing LSRC if there are problems?

elameno

elameno

2010-07-07 18:40

reporter   ~12374

No worries on the delay!

I wouldn't mind joining the team if you need someone; however, the time that I can dedicate to the project will be sporadic at best, since my work with Lime is purely a part of a project that I've implemented here at LeTourneau U to automate end of course surveys. If I were a part of the team, bug reports and feature requests would accrue for a while and then when I revisit this project I could knock out some issues. The time between when I revisit the project could be quite lengthy though (months or even more than a year) :-\

I would be happy to help implement the getResults feature and any of the other bug fixes that I've submitted to this point though.

In the longer term, given the limited time I can offer it might be best for me to just continue giving patches as I can. Let me know what your thoughts are on the matter.

Thanks,
Dave

c_schmitz

c_schmitz

2010-07-12 17:20

administrator   ~12386

I guess you are right ;).

Issue History

Date Modified Username Field Change
2010-04-08 18:08 elameno New Issue
2010-04-08 18:08 elameno File Added: sendReminder_fix.diff
2010-04-08 18:09 elameno File Added: lsrc.helper.php
2010-04-08 18:09 elameno Note Added: 11601
2010-04-11 00:29 c_schmitz Status new => assigned
2010-04-11 00:29 c_schmitz Assigned To => rakete
2010-07-05 17:43 c_schmitz Assigned To rakete => c_schmitz
2010-07-05 17:47 c_schmitz Note Added: 12355
2010-07-05 17:47 c_schmitz Status assigned => feedback
2010-07-07 18:40 elameno Note Added: 12374
2010-07-07 18:40 elameno Status feedback => assigned
2010-07-12 17:20 c_schmitz Note Added: 12386
2010-07-12 17:20 c_schmitz Status assigned => closed
2010-07-12 17:20 c_schmitz Resolution open => fixed
2011-10-20 18:29 c_schmitz Category RemoteControl => (No Category)