Skip to content

Commit

Permalink
Made sure createFieldMap is only called once per page at run-time:
Browse files Browse the repository at this point in the history
(1) stopped having EM force refresh
(2) converted key createFieldMap() run-time calls to use 'full', since that is what is needed at run-time, so no point to also create the 'short' version

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11123 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Oct 7, 2011
1 parent 8075576 commit 577d62b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions application/helpers/common_helper.php
Expand Up @@ -1878,7 +1878,7 @@ function getsidgidqidaidtype($fieldcode)
// but fails for type M and type P multiple choice
// questions because the SESSION fieldcode is combined
// and we want here to pass only the sidXgidXqid for type M and P
$fields=arraySearchByKey($fieldcode, createFieldMap($fsid), "fieldname", 1);
$fields=arraySearchByKey($fieldcode, createFieldMap($fsid,'full'), "fieldname", 1);

if (count($fields) != 0)
{
Expand Down Expand Up @@ -2495,7 +2495,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$aquery.=" ORDER BY group_order, question_order"; */
$CI->load->model('conditions_model');
$CI->load->model('defaultvalues_model');
$aresult = $CI->conditions_model->getConditions($surveyid,$questionid,$s_lang) or safe_die ("Couldn't get list of questions in createFieldMap function.<br />$query<br />"); //Checked
$aresult = $CI->conditions_model->getConditions($surveyid,$questionid,$s_lang) or safe_die ("Couldn't get list of questions in createFieldMap function.<br />".$CI->db->last_query()."<br />"); //Checked

foreach ($aresult->result_array() as $arow) //With each question, create the appropriate field(s))
{
Expand Down Expand Up @@ -3163,7 +3163,7 @@ function buildLabelSetCheckSumArray()
FROM ".db_table_name('labels')."
WHERE lid={$row['lid']}
ORDER BY language, sortorder, code"; */
$result2 = $CI->labels_model->getLabelCodeInfo($row['lid']) or show_error("safe_died querying labelset $lid<br />"); //Checked
$result2 = $CI->labels_model->getLabelCodeInfo($row['lid']) or show_error("safe_died querying labelset ".$row['lid']."<br />"); //Checked
foreach ($result2->result_array() as $row2)
{
$thisset .= implode('.', $row2);
Expand Down Expand Up @@ -4874,7 +4874,8 @@ function getArrayFilterExcludesForQuestion($qid)
$dbprefix = $CI->db->dbprefix;

// TODO: Check list_filter values to make sure questions are previous?
$surveyid = $CI->config->item('sid');
// $surveyid = $CI->config->item('sid');
$surveyid=returnglobal('sid');
$qid=sanitize_int($qid);

if (isset($cache[$qid])) return $cache[$qid];
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -540,7 +540,7 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force

// TODO - should these arrays only be built for questions that require substitution at run-time?
$ansList = '';
if (!is_null($ansArray)) {
if (isset($ansArray) && !is_null($ansArray)) {
$answers = array();
foreach ($ansArray as $key => $value) {
$answers[] = "'" . $key . "':'" . htmlspecialchars(preg_replace('/[[:space:]]/',' ',$value),ENT_QUOTES) . "'";
Expand Down Expand Up @@ -795,7 +795,7 @@ static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid=
$LEM->qid2code = array(); // List of codes for each question - needed to know which to NULL if a question is irrelevant
$LEM->jsVar2qid = array();

if (!is_null($surveyid) && $LEM->setVariableAndTokenMappingsForExpressionManager($surveyid,true,$anonymized,$LEM->allOnOnePage))
if (!is_null($surveyid) && $LEM->setVariableAndTokenMappingsForExpressionManager($surveyid,false,$anonymized,$LEM->allOnOnePage))
{
// means that some values changed, so need to update what was registered to ExpressionManager
$LEM->em->RegisterVarnamesUsingMerge($LEM->knownVars);
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/frontend_helper.php
Expand Up @@ -872,7 +872,7 @@ function checkUploadedFileValidity($surveyid, $move, $backok=null)
if (!isset($backok) || $backok != "Y")
{
global $dbprefix;
$fieldmap = createFieldMap($surveyid);
$fieldmap = createFieldMap($surveyid,'full');

if (isset($_POST['fieldnames']) && $_POST['fieldnames']!="")
{
Expand Down Expand Up @@ -979,7 +979,7 @@ function aCheckInput($surveyid, $move,$backok=null)
if (!isset($backok) || $backok != "Y")
{
global $dbprefix;
$fieldmap=createFieldMap($surveyid);
$fieldmap=createFieldMap($surveyid, 'full');
if (isset($_POST['fieldnames']))
{
$fields=explode("|", $_POST['fieldnames']);
Expand Down
2 changes: 1 addition & 1 deletion application/libraries/Save.php
Expand Up @@ -188,7 +188,7 @@ function run($args) {
elseif (isset($move))
{
// This else block is only there to take care of date conversion if the survey is not active - otherwise this is done in creatInsertQuery
$fieldmap=createFieldMap($surveyid); //Creates a list of the legitimate questions for this survey
$fieldmap=createFieldMap($surveyid,'full'); //Creates a list of the legitimate questions for this survey
$inserts=array_unique($_SESSION['insertarray']);
foreach ($inserts as $value)
{
Expand Down

0 comments on commit 577d62b

Please sign in to comment.