Skip to content

Commit

Permalink
Fixed issue PHP versions of EM functions sprintf and trig (sin/cos/ta…
Browse files Browse the repository at this point in the history
…n/etc.) not working

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@12020 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Jan 13, 2012
1 parent 2fc9c92 commit 322eb89
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions classes/eval/ExpressionManager.php
Expand Up @@ -2019,7 +2019,15 @@ private function RDP_RunFunction($funcNameToken,$params)
return false;
}
if (!$this->RDP_onlyparse) {
$result = $funcName($params);
switch($funcName) {
case 'sprintf':
// PHP doesn't let you pass array of parameters to sprintf, so must use call_user_func_array
$result = call_user_func_array('sprintf',$params);
break;
default:
$result = $funcName($params);
break;
}
}
// Call function with the params passed
} elseif (in_array($argsPassed, $numArgsAllowed)) {
Expand All @@ -2043,7 +2051,7 @@ private function RDP_RunFunction($funcNameToken,$params)
case 'sin':
case 'sqrt':
case 'tan':
if (is_float($params[0]))
if (is_numeric($params[0]))
{
$result = $funcName(floatval($params[0]));
}
Expand All @@ -2062,7 +2070,7 @@ private function RDP_RunFunction($funcNameToken,$params)
if (!$this->RDP_onlyparse) {
switch($funcName) {
case 'atan2':
if (is_float($params[0]) && is_float($params[1]))
if (is_numeric($params[0]) && is_numeric($params[1]))
{
$result = $funcName(floatval($params[0]),floatval($params[1]));
}
Expand Down

0 comments on commit 322eb89

Please sign in to comment.