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

Fix/896 criteria strict comparison #897

Closed
wants to merge 3 commits into from
Closed

Fix/896 criteria strict comparison #897

wants to merge 3 commits into from

Conversation

lenybernard
Copy link
Contributor

Type

Bugfix

Purpose

Fixes #896

And add the different operand which was missing (the opposite of equal).

BC Break

NO

@@ -77,7 +80,10 @@ protected function assert($value, $operator, $expected)
$result = false;
switch ($operator) {
case self::OPERAND_EQUAL:
$result = $value === $expected;
$result = $value == $expected;
Copy link
Member

@alexislefebvre alexislefebvre Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it break the existing widgets when Victoire will be updated? The comparison will be less strict so it may yield different results.

Another solution to keep backward compatibility would be to keep the existing comparison, and add a OPERAND_NOT_STRICTLY_EQUAL, but this is ugly. So your solution is the best we can do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be safer to convert $expected to true or false when equals to 1 or 0, then do a === comparison.
== comparison seems not sufficient strict because of true == 'false' returning true

Copy link
Contributor Author

@lenybernard lenybernard May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $value variable isn't always a boolean, we cannot cast it in bool.
I think our problem here is deeper and we need to dig more for a good architecture.
What do we do with this PR ? There isn't any BC break but we don't need this code neither as there is a workaround by using the OPERAND_TRUE instead the OPERAND_EQUAL for now so... we can take our time if you prefer @paulandrieux

@lenybernard
Copy link
Contributor Author

closing for now as the whole criteria system needs to be refactored and the issue isn't blocking

@lenybernard lenybernard deleted the fix/896-criteria-strict-comparison branch May 31, 2017 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants