From ce700643f571b95071457191d7c83f691cdcc92f Mon Sep 17 00:00:00 2001 From: Tech-Maou <44967339+Tech-Maou@users.noreply.github.com> Date: Wed, 31 Mar 2021 17:18:39 +0200 Subject: [PATCH] Update for strict comparison with === problem: loose comparison with == -> Null = "0" solved: strict comparison with === -> Null = false new session with $v1 = 0 and $v2 = 0 did lead to true answer with actually no answer given (Null -> "0") 0 + 0 = 0 -> true ref: https://www.php.net/manual/en/types.comparisons.php --- code/MathSpamProtectorField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/MathSpamProtectorField.php b/code/MathSpamProtectorField.php index 7ac91b6..e124c43 100644 --- a/code/MathSpamProtectorField.php +++ b/code/MathSpamProtectorField.php @@ -151,7 +151,7 @@ class MathSpamProtectorField extends TextField $word = MathSpamProtectorField::digit_to_word($v1 + $v2); - return ($word == strtolower($answer) || ($this->config()->get('allow_numeric_answer') && (($v1 + $v2) == $answer))); + return ($word == strtolower($answer) || ($this->config()->get('allow_numeric_answer') && (($v1 + $v2) === $answer))); } /**