codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
43 stars 24 forks source link

Error on Contao 4.10 with SimpleTokenParser and new Expression Syntax #150

Closed contaoacademy closed 3 years ago

contaoacademy commented 3 years ago

Affected version(s) Contao 4.10

Description I added the extension "Notification Center" and tested the new feature "Simple Token with Expression Syntax". https://github.com/contao/contao/pull/1509

Setup Simple Contao form with 2 numeric fields

Here's my Expression:

{if form_wert1+form_wert2<10}
sum lower than 10
{endif}

{if form_wert1+form_wert2>=10}
sum greater or equal to 10
{endif}

After submitting the form, I get the following error:

[2020-08-10 09:19:33] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Variable "form_wert2HASTE" is not valid around position 12 for expressionform_wert1+form_wert2HASTE-TAG-OPEN-64c8ab8e1ad15fedebbabc3ef6cc9cc810." at /www/htdocs/xxx/xxx/demo1/vendor/contao/core-bundle/src/Util/SimpleTokenParser.php line 133 {"exception":"[object] (InvalidArgumentException(code: 0): Variable \"form_wert2HASTE\" is not valid around position 12 for expressionform_wert1+form_wert2HASTE-TAG-OPEN-64c8ab8e1ad15fedebbabc3ef6cc9cc810. at /www/htdocs/xxx/xxx/demo1/vendor/contao/core-bundle/src/Util/SimpleTokenParser.php:133, Symfony\\Component\\ExpressionLanguage\\SyntaxError(code: 0): Variable \"form_wert2HASTE\" is not valid around position 12 for expressionform_wert1+form_wert2HASTE-TAG-OPEN-64c8ab8e1ad15fedebbabc3ef6cc9cc810. at /www/htdocs/xxx/xxx/demo1/vendor/symfony/expression-language/Parser.php:203)"} []

Also see: https://github.com/contao/contao/issues/2130

qzminski commented 3 years ago

@Toflar would you mind taking a look at this one? It looks related to your PR.

Toflar commented 3 years ago

@contaoacademy you may check the changes in https://github.com/codefog/contao-haste/pull/151 and see if this works for you :)

contaoacademy commented 3 years ago

@Toflar Thanks. I tested the fix and it works as expected.

Toflar commented 3 years ago

Released as 4.24.8.