View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
04281Bug reportsSurvey takingpublic2010-05-05 10:28
ReporterDenisChenu Assigned Tolemeur  
PriorityurgentSeverityminor 
Status closedResolutionfixed 
Product Version1.87+ 
Summary04281: Undefined Offset with some survey
Description

I made a demo survey for a user in the forum, i don't know how can i do, but the first group was empty.

I test the survey, first group doesn't show (there are no question inside), the if i clic to previous : survey hang and i had this in http log:

PHP Notice: Undefined offset: -1 in /limesurvey-path/group.php on line 65
PHP Notice: Undefined offset: -2 in /limesurvey-path/group.php on line 65

Steps To Reproduce

Import survey join, activate and test

OR

create a survey with first group empty, clic on previous button at first group and enjoy

Additional Information

Patch:
[Shnoulle@belgarath html]$ diff group.php group_patched.php
65c65
< while(checkgroupfordisplay($_SESSION['grouplist']$_SESSION['step']-1][0]) === false)

while(checkgroupfordisplay($_SESSION['grouplist']$_SESSION['step']-1][0]) === false && $_SESSION['grouplist'][$_SESSION['step']-1][0]>0 )

TagsNo tags attached.
Attached Files
limesurvey_survey_bugreport.csv (5,461 bytes)   
# LimeSurvey Survey Dump
# DBVersion 142
# This is a dumped survey from the LimeSurvey Script
# http://www.limesurvey.org/
# Do not change this header!

#
# SURVEYS TABLE
#
"sid","owner_id","admin","active","expires","startdate","adminemail","private","faxto","format","template","language","additional_languages","datestamp","usecookie","notification","allowregister","allowsave","autonumber_start","autoredirect","allowprev","printanswers","ipaddr","refurl","datecreated","publicstatistics","publicgraphs","listpublic","htmlemail","tokenanswerspersistence","assessments","usecaptcha","usetokens","bounce_email","attributedescriptions","emailresponseto","tokenlength"
"81516","1","Gsill","N","","","contact@gsill.net","Y","","G","default","fr","","N","N","0","N","Y","5","N","Y","N","N","N","2010-04-15","N","N","N","Y","N","N","D","N","contact@gsill.net","","","15"

#
# GROUPS TABLE
#
"gid","sid","group_name","group_order","description","language"
"87","81516","If i go back","1","","fr"
"88","81516","And now ?","2","","fr"
"89","81516","Empty group","0","","fr"

#
# QUESTIONS TABLE
#
"qid","sid","gid","type","title","question","preg","help","other","mandatory","lid","lid1","question_order","language"
"381","81516","87","T","Q1","If i go back : i have an error ","","","N","N","0","0","0","fr"
"382","81516","88","T","Try","Double go back ?","","","N","N","0","0","0","fr"

#
# ANSWERS TABLE
#

#
# CONDITIONS TABLE
#

#
# LABELSETS TABLE
#

#
# LABELS TABLE
#

#
# QUESTION_ATTRIBUTES TABLE
#
"qaid","qid","attribute","value"
"768","381","display_rows",""
"769","381","hidden","0"
"770","381","maximum_chars",""
"771","381","page_break","0"
"772","381","text_input_width",""
"773","381","time_limit",""
"774","381","time_limit_action","1"
"775","381","time_limit_message",""
"776","381","time_limit_message_delay",""
"777","381","time_limit_disable_next","0"
"778","381","time_limit_message_style",""
"779","381","time_limit_timer_style",""
"780","381","time_limit_warning",""
"781","381","time_limit_warning_display_time",""
"782","381","time_limit_warning_message",""
"783","381","time_limit_warning_style",""
"784","382","display_rows",""
"785","382","hidden","0"
"786","382","maximum_chars",""
"787","382","page_break","0"
"788","382","text_input_width",""
"789","382","time_limit",""
"790","382","time_limit_action","1"
"791","382","time_limit_message",""
"792","382","time_limit_message_delay",""
"793","382","time_limit_disable_next","0"
"794","382","time_limit_message_style",""
"795","382","time_limit_timer_style",""
"796","382","time_limit_warning",""
"797","382","time_limit_warning_display_time",""
"798","382","time_limit_warning_message",""
"799","382","time_limit_warning_style",""

#
# ASSESSMENTS TABLE
#

#
# SURVEYS_LANGUAGESETTINGS TABLE
#
"surveyls_survey_id","surveyls_language","surveyls_title","surveyls_description","surveyls_welcometext","surveyls_endtext","surveyls_url","surveyls_urldescription","surveyls_email_invite_subj","surveyls_email_invite","surveyls_email_remind_subj","surveyls_email_remind","surveyls_email_register_subj","surveyls_email_register","surveyls_email_confirm_subj","surveyls_email_confirm","surveyls_dateformat"
"81516","fr","Test undefined offset","It's OK ?","","","","","Invitation à participer à un questionnaire","Cher(e) {FIRSTNAME},<br /><br />Vous avez été invité à participer à un questionnaire.<br /><br />Celui-ci est intitulé :<br />""{SURVEYNAME}""<br /><br />""{SURVEYDESCRIPTION}""<br /><br />Pour participer, veuillez cliquer sur le lien ci-dessous.<br /><br />Cordialement,<br /><br />{ADMINNAME} ({ADMINEMAIL})<br /><br />----------------------------------------------<br />Cliquez ici pour remplir ce questionnaire :<br />{SURVEYURL}","Rappel pour participer à un questionnaire","Cher(e) {FIRSTNAME},<br /><br />Vous avez été invité à participer à un questionnaire récemment.<br /><br />Nous avons pris en compte que vous n'avez pas encore complété le questionnaire, et nous vous rappelons que celui-ci est toujours disponible si vous souhaitez participer.<br /><br />Le questionnaire est intitulé :<br />""{SURVEYNAME}""<br /><br />""{SURVEYDESCRIPTION}""<br /><br />Pour participer, veuillez cliquer sur le lien ci-dessous.<br /><br />Cordialement,<br /><br />{ADMINNAME} ({ADMINEMAIL})<br /><br />----------------------------------------------<br />Cliquez ici pour faire le questionnaire:<br />{SURVEYURL}","Confirmation de l'inscription au questionnaire","Cher(e){FIRSTNAME},<br /><br />Vous (ou quelqu'un utilisant votre adresse électronique) vous êtes enregistré pour participer à un questionnaire en ligne intitulé {SURVEYNAME}.<br /><br />Pour compléter ce questionnaire, cliquez sur le lien suivant :<br /><br />{SURVEYURL}<br /><br />Si vous avez des questions à propos de ce questionnaire, ou si vous ne vous êtes pas enregistré pour participer à celui-ci et croyez que ce courriel est une erreur, veuillez contacter {ADMINNAME} sur {ADMINEMAIL}","Confirmation de questionnaire complété","Cher(e) {FIRSTNAME},<br /><br />Ce courriel vous confirme que vous avez complété le questionnaire intitulé {SURVEYNAME} et que votre réponse a été enregistrée. Merci pour votre participation.<br /><br />Si vous avez des questions à propos de ce courriel, veuillez contacter {ADMINNAME} sur {ADMINEMAIL}.<br /><br />Cordialement,<br /><br />{ADMINNAME}","1"

#
# QUOTA TABLE
#

#
# QUOTA_MEMBERS TABLE
#

#
# QUOTA_LANGUAGESETTINGS TABLE
#

bug04281.patch (514 bytes)   
--- group.php	2010-04-15 19:41:27.000000000 +0200
+++ group_patched.php	2010-04-15 19:45:20.000000000 +0200
@@ -62,7 +62,7 @@
 $show_empty_group = false;
 if (isset($move) && $_SESSION['step'] != 0 && $move != "movesubmit")
 {
-	while(checkgroupfordisplay($_SESSION['grouplist'][$_SESSION['step']-1][0]) === false)
+	while(checkgroupfordisplay($_SESSION['grouplist'][$_SESSION['step']-1][0]) === false && $_SESSION['grouplist'][$_SESSION['step']][0]>0 )
 	{
 		if (isset($move) && $move == "moveprev") 
         {
bug04281.patch (514 bytes)   
bug04281-2.patch (349 bytes)   
--- group.php	2010-04-15 21:48:05.000000000 +0200
+++ group_patched.php	2010-04-15 21:47:54.000000000 +0200
@@ -67,6 +67,7 @@
 		if (isset($move) && $move == "moveprev") 
         {
             $_SESSION['step']=$_SESSION['step']-1;
+            if ($_SESSION['step']==0){ break;}
         }
 		if (isset($move) && $move == "movenext") 
         {
bug04281-2.patch (349 bytes)   
Bug heat8
Complete LimeSurvey version number (& build)8518
I will donate to the project if issue is resolved
BrowserFirefox
Database type & versionMySQL 5.1.44
Server OS (if known)Linux
Webserver software & version (if known)apache
PHP Version5.2.13

Users monitoring this issue

DenisChenu

Activities

DenisChenu

DenisChenu

2010-04-15 20:00

developer   ~11619

Last edited: 2010-04-15 20:01

Patch is not perfect : there are one PHP alert .

Duplicate : http://bugs.limesurvey.org/view.php?id=3451

DenisChenu

DenisChenu

2010-04-15 21:49

developer   ~11620

Oups,

another best patch
69a70

        if ($_SESSION['step']==0){ break;}
Mazi

Mazi

2010-04-22 12:02

updater   ~11631

Thibault, can you review this patch and commit it if everything is fine?

lemeur

lemeur

2010-04-23 08:41

developer   ~11633

Confirmed, thx for the report.

lemeur

lemeur

2010-04-23 08:42

developer   ~11634

Setting status as urgent cause this makes the webserver hang.

lemeur

lemeur

2010-04-23 09:42

developer   ~11635

The proposed patch isn't the correct one, but thanks for having investigated this.

The fix is implemented in rev 8620.

Note also that activating a survey with an empty group is "forbidden", that is to say that an empty-group pre-activation check must warn the user and prevent activation. But this check wasn't working.

Anyway, another fix was needed because even without activation, and empty group could hang the webserver in preview survey mode, when clicking Previous.

Many thanks for the report.
Thibault

DenisChenu

DenisChenu

2010-04-23 10:07

developer   ~11636

<quote>The proposed patch isn't the correct one, but thanks for having investigated this.</quote>
The second one don't work ?
I test it in production with the last LS release, with group, without group ... with good survey and with bad survey.

no php warning in my log, and all seem good. What is the option i don't tested.

<quote>Note also that activating a survey with an empty group is "forbidden"</quote> Even if it's forbidden, if there are a possibility to hang whole server, i think it's a good option to put something, no ?

lemeur

lemeur

2010-04-23 10:12

developer   ~11637

I'm not saying the second patch doesn't work, but the correct way is not to enter the while loop is the array index doesn't exist: otherwise we don't really know what could occur...
for instance, I've never tested what the checkgroupfordisplay should return if the parameter is undefined !! and even if it's working now, this doesn't mean this will work in the future... this is why I prefer to avoid entering the loop if the index is undefined.

<Quote>Even if it's forbidden, if there are a possibility to hang whole server, i think it's a good option to put something, no ? </Quote>

Of course, this is what I did in rev 8620: this patch fixes both the server hang AND the prevent empty-group activation bug.

Thibault

DenisChenu

DenisChenu

2010-04-23 12:47

developer   ~11640

OK,

Thank's for the explanation.

Sure avoid to entering the loop is the best solution!!

Issue History

Date Modified Username Field Change
2010-04-15 19:42 DenisChenu New Issue
2010-04-15 19:42 DenisChenu File Added: limesurvey_survey_bugreport.csv
2010-04-15 20:00 DenisChenu Note Added: 11619
2010-04-15 20:00 DenisChenu File Added: bug04281.patch
2010-04-15 20:01 DenisChenu Issue Monitored: DenisChenu
2010-04-15 20:01 DenisChenu Note Edited: 11619
2010-04-15 21:49 DenisChenu Note Added: 11620
2010-04-15 21:50 DenisChenu File Added: bug04281-2.patch
2010-04-22 12:01 Mazi Status new => assigned
2010-04-22 12:01 Mazi Assigned To => lemeur
2010-04-22 12:02 Mazi Note Added: 11631
2010-04-23 08:41 lemeur Note Added: 11633
2010-04-23 08:41 lemeur Status assigned => confirmed
2010-04-23 08:41 lemeur Priority normal => urgent
2010-04-23 08:42 lemeur Note Added: 11634
2010-04-23 09:42 lemeur Note Added: 11635
2010-04-23 09:42 lemeur Status confirmed => resolved
2010-04-23 09:42 lemeur Resolution open => fixed
2010-04-23 10:07 DenisChenu Note Added: 11636
2010-04-23 10:12 lemeur Note Added: 11637
2010-04-23 12:47 DenisChenu Note Added: 11640
2010-05-05 10:28 c_schmitz Status resolved => closed
2010-10-25 00:18 c_schmitz Category Survey at Runtime => Survey taking