From 5290f03ae29c44ae06c677ccb251f1f72ec527ce Mon Sep 17 00:00:00 2001 From: tmswhite Date: Tue, 7 Feb 2012 19:10:19 +0000 Subject: [PATCH] Fixed issue #05771: ExprMgr_process_relevance_and_tailoring need more and more time after page reload git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@12396 b72ed6b6-b9f8-46b5-92b4-906544132732 --- classes/eval/ExpressionManager.php | 10 ++++++++++ classes/eval/LimeExpressionManager.php | 8 +++++++- group.php | 6 +++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/classes/eval/ExpressionManager.php b/classes/eval/ExpressionManager.php index 3f3ee587ba7..543654789be 100644 --- a/classes/eval/ExpressionManager.php +++ b/classes/eval/ExpressionManager.php @@ -1937,6 +1937,16 @@ public function StartProcessingGroup($sid=NULL,$rooturl='',$hyperlinkSyntaxHighl $this->hyperlinkSyntaxHighlighting=$hyperlinkSyntaxHighlighting; } + /** + * Clear cache of tailoring content. + * When re-displaying same page, need to avoid generating double the amount of tailoring content. + */ + public function ClearSubstitutionInfo() + { + $this->substitutionNum=0; + $this->substitutionInfo=array(); // array of JavaScripts for managing each substitution + } + /** * Process multiple substitution iterations of a full string, containing multiple expressions delimited by {}, return a consolidated string * @param $src diff --git a/classes/eval/LimeExpressionManager.php b/classes/eval/LimeExpressionManager.php index 527ec28c39b..28b46031531 100644 --- a/classes/eval/LimeExpressionManager.php +++ b/classes/eval/LimeExpressionManager.php @@ -3408,6 +3408,7 @@ private function _UpdateValuesInDatabase($updatedValues, $finished=false) static function GetLastMoveResult() { $LEM =& LimeExpressionManager::singleton(); + $LEM->em->ClearSubstitutionInfo(); // need to avoid double-generation of tailoring info return (isset($LEM->lastMoveResult) ? $LEM->lastMoveResult : NULL); } @@ -4692,10 +4693,15 @@ static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid= /** * Should be called after each group finishes */ - static function FinishProcessingGroup() + static function FinishProcessingGroup($skipReprocessing=false) { // $now = microtime(true); $LEM =& LimeExpressionManager::singleton(); + if ($skipReprocessing) + { + $LEM->pageTailorInfo=array(); + $LEM->pageRelevanceInfo=array(); + } $LEM->pageTailorInfo[] = $LEM->em->GetCurrentSubstitutionInfo(); $LEM->pageRelevanceInfo[] = $LEM->groupRelevanceInfo; // $LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now)); diff --git a/group.php b/group.php index 66ea1c4449b..5a291204ba6 100644 --- a/group.php +++ b/group.php @@ -18,6 +18,7 @@ // $LEMdebugLevel - customizable debugging for Lime Expression Manager $LEMdebugLevel=0; // LEM_DEBUG_TIMING; // (LEM_DEBUG_TIMING + LEM_DEBUG_VALIDATION_SUMMARY + LEM_DEBUG_VALIDATION_DETAIL); +$LEMskipReprocessing=false; // true if used GetLastMoveResult to avoid generation of unneeded extra JavaScript switch ($thissurvey['format']) { case "A": //All in one @@ -93,6 +94,7 @@ // Simply re-display the current page without re-processing POST or re-validating input. Means user will lose whatever data entry the just tried // Also flash a message $moveResult = LimeExpressionManager::GetLastMoveResult(); + $LEMskipReprocessing=true; $move = "movenext"; // so will re-display the survey $invalidLastPage=true; $vpopup="