tonic icon indicating copy to clipboard operation
tonic copied to clipboard

`handleIfs()` replaces parts of variable names if they are "or"

Open nitricware opened this issue 6 years ago • 2 comments

The handleIfs() function replaces "or" in a variable name with ||.

This makes $selector to $select|| which results in an error because eval() fails.

This also happens with the conditions. {$selector eq "portfolio"} becomes `{$select|| eq "p||tfolio"}

nitricware avatar Nov 04 '18 14:11 nitricware

Stupid idea to fix this issue. At https://github.com/rgamba/tonic/blob/master/src/Tonic.php#L826 replace edit every items of arrays in str_replace() adding whitespaces before and after, eg.:

$condition=str_replace(array(
   ' eq ',
   ' gt ',
   ...
 ),array(
    ' == ',
   ' > ',
...
),$condition);

adaniello avatar Feb 15 '19 12:02 adaniello

Actually, I think that's a great solution.

nitricware avatar Feb 15 '19 20:02 nitricware