Skip to content

Commit

Permalink
Fixed issue #06214: relevance equations that only contain static repl…
Browse files Browse the repository at this point in the history
…acement values cause JS crash
  • Loading branch information
TMSWhite committed Jun 13, 2012
1 parent f37af29 commit 25a5451
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion classes/expressions/ExpressionManager.php
Expand Up @@ -1298,7 +1298,10 @@ public function GetJavaScriptEquivalentOfExpression()
{
if (!preg_match("/^.*\.(NAOK|relevanceStatus)$/", $var))
{
$nonNAvarsUsed[] = $var;
if ($this->GetVarAttribute($var,'jsName','') != '')
{
$nonNAvarsUsed[] = $var;
}
}
}
$mainClause = implode('', $stringParts);
Expand Down
7 changes: 4 additions & 3 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -5891,14 +5891,15 @@ static function GetRelevanceAndTailoringJavaScript()

$relChangeVars[] = " relChange" . $arg['qid'] . "=false;\n"; // detect change in relevance status

if (($relevance == '' || $relevance == '1') && count($tailorParts) == 0 && count($subqParts) == 0 && count($subqValidations) == 0 && count($validationEqns) == 0)
if (($relevance == '' || $relevance == '1' || ($arg['result'] == true && $arg['numJsVars']==0)) && count($tailorParts) == 0 && count($subqParts) == 0 && count($subqValidations) == 0 && count($validationEqns) == 0)
{
// Only show constitutively true relevances if there is tailoring that should be done.
$relParts[] = "$('#relevance" . $arg['qid'] . "').val('1'); // always true\n";
$GalwaysRelevant[$arg['gseq']] = true;
continue;
}
$relevance = ($relevance == '') ? '1' : $relevance;
// don't show equation if it is static - e.g. exclusively comparisons against token values
$relevance = ($relevance == '' || ($arg['result'] == true && $arg['numJsVars']==0)) ? '1' : $relevance;

$relParts[] = "\nif (" . $relevance . ")\n{\n";
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -6176,7 +6177,7 @@ static function GetRelevanceAndTailoringJavaScript()
$relParts[] = " $('#relevance" . $arg['qid'] . "').val('1');\n";

$relParts[] = "}\n";
if (!($relevance == '' || $relevance == '1'))
if (!($relevance == '' || $relevance == '1' || ($arg['result'] == true && $arg['numJsVars']==0)))
{
if (!isset($dynamicQinG[$arg['gseq']]))
{
Expand Down

0 comments on commit 25a5451

Please sign in to comment.