View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
18862Bug reportsExpression Managerpublic2023-08-18 17:42
ReporterCoreyfournier Assigned To 
PrioritynoneSeveritypartial_block 
Status feedbackResolutionopen 
Product Version6.1.x 
Summary18862: Expression manager doesn't resolve jsName
Description

In the file em_manager_helper there is a logic error that never resolves jsName or JsName_on. This is in the function _GetVarAttribute.

In the case JsName the logic is below:

return (isset($var['jsName_on']) ? $var['jsName_on'] : isset($var['jsName'])) ? $var['jsName'] : $default;

It has nested inline if statements. The first in line is passed to the next. The output of the first if is not a boolean "$var['jsName_on']", but the second is "isset($var['jsName'])". The whole statement is basically jacked up as it's a string as input into another if statement.

This isn't the only problem as the below code in the function setVariableAndTokenMappingsForExpressionManager always clears out js name on. So "isset($var['jsName_on'])" is always true and set to an empty string.

        // Hidden question are never on same page (except for equation)
        if ($hidden && $type != Question::QT_ASTERISK_EQUATION) {
            $jsVarName_on = '';
        }

I think the logic should be rewritten as follows :

if(isset($var['jsName']))
return $var['jsName'];
else if(isset($var['jsName_on']))
return $var['jsName_on'];
else
return $default;

Steps To Reproduce

Steps to reproduce

Add a question and an expression to use the Question.jsName.

Expected result

java{SurveyId}X{Id}X{Id}

Actual result

Nothing

(Write here what happened instead)

TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)6.1
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMysql
Server OS (if known)
Webserver software & version (if known)
PHP VersionLatest

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2023-06-06 17:56

developer   ~75451

The function clear jsVarName_on for hidden question.

Hidden question are not in page, there don't have a jsVarName

Add a question and an expression to use the Question.jsName.

Please : a sample survey

tibor.pacalat

tibor.pacalat

2023-08-17 15:48

administrator   ~76632

@Coreyfournier could you please provide a sample survey where this is happening?

Issue History

Date Modified Username Field Change
2023-06-06 17:35 Coreyfournier New Issue
2023-06-06 17:56 DenisChenu Note Added: 75451
2023-06-06 17:56 DenisChenu Bug heat 0 => 2
2023-08-17 15:48 tibor.pacalat Assigned To => tibor.pacalat
2023-08-17 15:48 tibor.pacalat Status new => feedback
2023-08-17 15:48 tibor.pacalat Note Added: 76632
2023-08-17 15:48 tibor.pacalat Bug heat 2 => 4
2023-08-18 17:42 tibor.pacalat Assigned To tibor.pacalat =>