diff --git a/application/helpers/expressions/em_core_helper.php b/application/helpers/expressions/em_core_helper.php index 2132a415fdb..0c6255064b1 100644 --- a/application/helpers/expressions/em_core_helper.php +++ b/application/helpers/expressions/em_core_helper.php @@ -1668,11 +1668,22 @@ public function sProcessStringContainingExpressions($src, $questionNum = 0, $num $prettyPrint = ''; $errors = array(); + $prettyPrintIterationDone = false; for ($i = 1; $i <= $numRecursionLevels; ++$i) { // TODO - Since want to use for dynamic substitution, what if there are recursive substititons? + $prevResult = $result; $result = $this->sProcessStringContainingExpressionsHelper($result, $questionNum, $staticReplacement); + if($result === $prevResult) { + // No update during process : can exit of iteration + if(!$prettyPrintIterationDone) { + $prettyPrint = $this->prettyPrintSource; + } + // No need errors : already done + break; + } if ($i == $whichPrettyPrintIteration) { $prettyPrint = $this->prettyPrintSource; + $prettyPrintIterationDone = true; } $errors = array_merge($errors, $this->RDP_errs); } @@ -1962,10 +1973,20 @@ private function RDP_SetVariableValue($op, $name, $value) */ public function asSplitStringOnExpressions($src) { + // Empty string, return an array + if($src === "") { + return array(); + } + // No replacement to do, preg_split get more time than strpos + if(strpos($src, "{") === false || $src==="{" || $src==="}") { + return array ( + 0 => array ($src,0,'STRING') + ); + }; + // Seems to need split and replacement $parts = preg_split($this->RDP_ExpressionRegex, $src, -1, (PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)); - $count = count($parts); $tokens = array(); $inSQString = false; diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index df1fc714cf2..2ab528b1c27 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -347,12 +347,14 @@ class LimeExpressionManager { * current Group sequence (0-based index) * @example 1 * @var integer + * @deprecated : not updated in this class */ private $currentGroupSeq; /** * for Question-by-Question mode, the 0-based index * @example 3 * @var integer + * @deprecated : not updated in this class */ private $currentQuestionSeq; /**