Closed coopan closed 1 year ago
I didn't even know we support the ternary... we do have a feature request for it. Will have to look into this
OK, we definitely support the ternary. There are no unit tests for it though and it's not documented either. Anyway, I cannot reproduce this on any PHP-version (7.2 t/m 8.2)
v4.3.0
1 equals 1<br />
2 equals 2<br />
3 equals 3<br />
4 equals 4
I'm running Smarty v4.2.1 on PHP v8.0.27 and I cannot confirm either. Copy and pasting the exact example above I get:
1 equals 1
2 equals 2
3 equals 3
4 equals 4
Thanks @wisskid and @scottchiefbaker!
Very weird and points to something odd with our setup. Strange that it would exhibit this behaviour on 4.3.0 but simply using composer to revert to 3.1.47 and nothing else corrects it.
We'll have a dig and post back here when we know. Do you know what version ternary was added? I wonder if predecessors have added an extension somewhere to support it on 3.x and it doesn't play nice with 4.x.
I thought it might have something to do with your PHP but I tested the sample above with PHP: v7.0, v7.1, v7.2, v7.3, v7.4, v8.0, and v8.1 and they all work fine.
Smarty version: 4.3.0 PHP version: 7.4
We recently upgraded from 3.1.47 to 4.3.0. We have a few templates that use ternary conditions with exact matches that were giving some weird output after the upgrade.
We had a bit of a play around with some literals in templates and reproduced the issue, confirming that switching back to 3.1.47 corrected the issue. Also tested exact match operator in a normal if condition. It seems this is specific to exact match and exact not match only when used in a ternary. In reality we are comparing a literal to a variable, so the below isolated type issues coming from those variables.
Examples
On 4.3.0
On 3.1.47, all seems as expected
I've had a dig through the issues here and the changelog, but don't see anything about a change to ternary operator. Have we missed something in the 4.x upgrade?