Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] Fixed issue #15532: Show warnings when implicit alphabetical compare #1341

Merged
merged 19 commits into from Nov 11, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Dev: Add warning on +

  • Loading branch information...
Shnoulle committed Nov 7, 2019
commit b7cd1c43c330c6211164c6a23e7248e4489c2d8c
@@ -347,19 +347,19 @@ public function RDP_EvaluateBinary(array $token)
$bMismatchType = false;
$arg1[0] = strval($arg1[0]);
$arg2[0] = strval($arg2[0]);
$this->RDP_AddWarning(self::gT("This expression uses alphabetical compare. Are you sure you didn't mean numerical compare? See manual about strcmp and intval for more information.",'unescaped'), $token, "https://manual.limesurvey.org/Expression_Manager#Access_to_Functions");
$this->RDP_AddWarning(self::gT("This expression uses alphabetical compare. Are you sure you didn't mean numerical compare? See manual about strcmp and intval for more information.",'unescaped'), $token, "https://manual.limesurvey.org/Expression_Manager#Warning_with_mismatch_number_and_string_and_force_comparisons_as_string");
$asWarning = true;
}
}
if($bIsCompare && $bMismatchType) {
/* Add the warning */
/* Add the warning */
$this->RDP_AddWarning(self::gT("This expression compare values with different type: this can broke internet (really).",'unescaped'), $token);
$asWarning = true;
}
$aPotentialStringArray = array('DQ_STRING', 'SQ_STRING', 'STRING', 'WORD', 'SGQA');
$aPotentialStringArray = array('WORD', 'SGQA');
if ($bIsCompare && !$asWarning && ((isset($arg1[2]) && in_array($arg1[2], $aPotentialStringArray) || (isset($arg2[2]) && in_array($arg2[2], $aPotentialStringArray))))) {
$this->RDP_AddWarning(self::gT("This expression compare 2 values that can be numeric but string too. Are you sure you didn't mean numerical compare? See manual about strcmp and intval for more information.",'unescaped', "https://manual.limesurvey.org/Expression_Manager#Access_to_Functions"), $token, "https://manual.limesurvey.org/Expression_Manager#Access_to_Functions");
$this->RDP_AddWarning(self::gT("This expression compare 2 values that can be numeric but string too. Are you sure you didn't mean numerical compare? See manual about strcmp and intval for more information.",'unescaped', "https://manual.limesurvey.org/Expression_Manager#Warning_with_mismatch_number_and_string_and_force_comparisons_as_string"));
}
switch (strtolower($token[0])) {
@@ -431,8 +431,10 @@ public function RDP_EvaluateBinary(array $token)
break;
case '+':
if ($bBothNumeric) {
$this->RDP_AddWarning(self::gT("Usage of + with numeric value, youn can replace with sum.",'unescaped'),$token, "https://manual.limesurvey.org/Expression_Manager#Warning_with_plus_operator_.28.2B.29")
$result = array(($arg1[0] + $arg2[0]), $token[1], 'NUMBER');
} else {
$this->RDP_AddWarning(self::gT("Usage of + with string value, youn can replace with join.",'unescaped'),$token, "https://manual.limesurvey.org/Expression_Manager#Warning_with_plus_operator_.28.2B.29")
$result = array($arg1[0].$arg2[0], $token[1], 'STRING');
}
break;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.