Project

General

Profile

Actions

Bug #99130

open

Form Variants: Dynamic validators on formValues break in PHP 8

Added by David Nax over 1 year ago. Updated 11 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2022-11-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Since Version 8 PHP breaks when array key not exists. This affects the usage of dynamic validators of form variants as documented here:
https://docs.typo3.org/c/typo3/cms-form/11.5/en-us/I/Concepts/Variants/Index.html#adding-validators-dynamically.

When we use e.g.

condition: 'formValues["country"] == "GB"'

we get the following error
#1476107295 TYPO3\CMS\Core\Error\Exception
PHP Warning: Undefined array key "country" in /var/www/html/vendor/symfony/expression-language/Node/GetAttrNode.php line 97

A possible explanation is that in TYPO3\CMS\Form\Domain\Runtime\FormRuntime , processVariants() is called a number of times (also when the form is initially rendered), but the formValues (which are filled from the formState and the request arguments, see lines 1124ff. ) remain empty until they are filled later. The condition matcher ( line 476 ) then is invoked to match the condition against an empty array with no keys, resulting in the above error.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #94707: Undefined array key / Trying to access array offset on value of type null / PHP Version 8.0.8Closed2021-08-04

Actions
Related to TYPO3 Core - Bug #95781: PHP Warning: Undefined array key "uid" in /app/vendor/symfony/expression-language/Node/GetAttrNode.phpRejected2021-10-26

Actions
Actions

Also available in: Atom PDF