View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
04399Bug reportsSurvey takingpublic2010-06-08 21:51
Reporterjdalegonzalez Assigned Tomachaven  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.87+ 
Fixed in Version1.90RC1 
Summary04399: limesurvey/index.php line 1072 could break out of foreach on successful find.
Description

// record the qid and question type for future use
foreach ($_SESSION['fieldarray'] as $sfa)
{
if ($sfa[1] == $masterFieldName)
{
$value_qid=$sfa[0];
$value_type=$sfa[4];
}
}

That code is trying to find the field to be checked in the session fieldarray. Since there should only be one matching field, once $value_qid and $value_type have been set, the code could break the foreach, potentially speeding up execution of the condition. Even better would be keying session fields off of their name (ie $value_qid = $_SESSION[fieldarray][$masterFieldName][0]) to prevent the linear lookup, but maybe there is something I'm missing about the fieldarray that prevents this.

Steps To Reproduce

look at the code at 1072 and verify my conclusion

TagsNo tags attached.
Bug heat2
Complete LimeSurvey version number (& build)8488
I will donate to the project if issue is resolved
Browserall
Database type & versionall
Server OS (if known)all
Webserver software & version (if known)all
PHP Versionall

Users monitoring this issue

There are no users monitoring this issue.

Activities

jdalegonzalez

jdalegonzalez

2010-06-07 21:35

reporter   ~12201

I continued looking at the code and it occurs to me that right below the block in question, the code does the same foreach ($_SESSION['fieldarray'] as $sfa). It seems like the best solution would be to combine the two loops together, setting $value_qid and $value_type inside the second foreach (which is much more complicated and doing many more things). That would remove above loop entirely.

Issue History

Date Modified Username Field Change
2010-06-07 21:29 jdalegonzalez New Issue
2010-06-07 21:29 jdalegonzalez Status new => assigned
2010-06-07 21:29 jdalegonzalez Assigned To => user372
2010-06-07 21:35 jdalegonzalez Note Added: 12201
2010-06-08 11:05 machaven Assigned To user372 => machaven
2010-06-08 11:14 machaven Status assigned => resolved
2010-06-08 11:14 machaven Fixed in Version => 1.90RC1
2010-06-08 11:14 machaven Resolution open => fixed
2010-06-08 21:51 c_schmitz Status resolved => closed
2010-10-25 00:18 c_schmitz Category Survey at Runtime => Survey taking