Broken computed twig field behavior

Created on 15 March 2023, over 1 year ago
Updated 21 March 2023, over 1 year ago

Problem/Motivation

Steps to reproduce

1) Create a new webform or use existed.
2) Add a new fields with "integer" type.
3) Add a new field with "computed twig" type and define some math in this field (e.g. integer_field1 + integer_field2).
4) Up to version 6.1.4 (version 6.1.3. and below) computed twig has worked correctly with any math operations for integer type fields at least.
5) After upgrade to 6.1.4 a see the errors:
TypeError: Unsupported operand types: string + string в __TwigTemplate_bfbe80d8718ade6a257b26a4b227924a->doDisplay() (строка 39 из /var/www/html/***/web/sites/default/files/php/twig/641018ae23296___string_template__a5e22e_Rn-FNXHTsTJtUZJ-SBX7BYDy6/OBR8lut5eq4XgaocKlwHwG6ag6RUqxkUkrl7oIB3_1M.php)

Here the line 39 from generated twig template:
echo $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, ((twig_get_attribute($this->env, $this->source, ($context["data"] ?? null), "integer_field_1", [], "any", false, false, true, 1) + twig_get_attribute($this->env, $this->source, ($context["data"] ?? null), "integer_field_2", [], "any", false, false, true, 1)) / 2), "html", null, true);

In my example, I'm trying to add two fields and divide the sum by 2 (this worked fine until the module was upgraded to version 6.1.4)

6) When I try to follow the webform result page or any submission with computed twig fields site just show me the error "The website encountered an unexpected error. Please try again later."

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Closed: duplicate

Version

6.1

Component

Code

Created by

🇷🇺Russia msidiagnos

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024