From 0c41165aecf26eb2d08697fd3d29b701f077268e Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Thu, 22 Nov 2018 15:14:00 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20#14270:=20value,=20valueNAOK=20?= =?UTF-8?q?etc=20=E2=80=A6=20broken=20with=20GET=20params=20Dev:=20remove?= =?UTF-8?q?=20usage=20of=20LimeExpressionManager=20in=20prefillFromCommand?= =?UTF-8?q?Line=20function=20Dev:=20since=20it=20can=20broke=20a=20lot=20E?= =?UTF-8?q?M=20:=20log=20potential=20error=20in=20setVariableAndTokenMappi?= =?UTF-8?q?ngsForExpressionManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/expressions/em_manager_helper.php | 5 ++++- application/helpers/frontend_helper.php | 17 +++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index 924059eb5fc..ad8de729aaf 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -3623,7 +3623,10 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force $now = microtime(true); $this->em->SetSurveyMode($this->surveyMode); $survey = Survey::model()->findByPk($surveyid); - + if(empty($this->surveyOptions)) { + /* Log it as error : this need some test */ + Yii::log('setVariableAndTokenMappingsForExpressionManager with an empty surveyOptions.','error','application.LimeExpressionManager'); + } // TODO - do I need to force refresh, or trust that createFieldMap will cache langauges properly? $fieldmap=createFieldMap($survey,$style='full',$forceRefresh,false,$_SESSION['LEMlang']); $this->sid= $surveyid; diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index 7a334d79646..ce3fb0523e2 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -881,22 +881,19 @@ function prefillFromCommandLine($surveyid) if (Yii::app()->getRequest()->getRequestType()=='GET') { $getValues = array_diff_key($_GET,array_combine($reservedGetValues, $reservedGetValues)); if(!empty($getValues)) { - $qcode2sgqa = LimeExpressionManager::getLEMqcode2sgqa($surveyid); + $qcode2sgqa = array(); + Yii::import('application.helpers.viewHelper'); + foreach ($_SESSION['survey_'.$surveyid]['fieldmap'] as $sgqa => $details) { + $qcode2sgqa[viewHelper::getFieldCode($details,array('LEMcompat'=>true))] = $sgqa; + } foreach ($getValues as $k=>$v) { + tracevar($k); if (isset($_SESSION['survey_'.$surveyid]['fieldmap'][$k])) { // sXgXqa prefilling $startingValues[$k] = $v; - } elseif( !empty($qcode2sgqa) && array_key_exists($k,$qcode2sgqa) ) { + } elseif( array_key_exists($k,$qcode2sgqa) ) { // EM code prefilling $startingValues[$qcode2sgqa[$k]] = $v; - /* Alternative - foreach ($_SESSION['survey_'.$surveyid]['fieldmap'] as $sgqa => $details) { - // Need Yii::import('application.helpers.viewHelper'); - if (viewHelper::getFieldCode($details,array('LEMcompat'=>true)) == $k) { - $startingValues[$sgqa] = $v; - } - } - */ } } }