Bug #99130
closedForm Variants: Dynamic validators on formValues break in PHP 8
0%
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.
Updated by Gerrit Code Review about 2 years ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Gerrit Code Review about 2 years ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Gerrit Code Review almost 2 years ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Gerrit Code Review almost 2 years ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Felix Nagel almost 2 years ago
- Related to Bug #94707: Undefined array key / Trying to access array offset on value of type null / PHP Version 8.0.8 added
Updated by Felix Nagel almost 2 years ago
- Related to Bug #95781: PHP Warning: Undefined array key "uid" in /app/vendor/symfony/expression-language/Node/GetAttrNode.php added
Updated by Gerrit Code Review over 1 year ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Gerrit Code Review over 1 year ago
Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Gerrit Code Review over 1 year ago
Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693
Updated by Georg Ringer 5 months ago
- Status changed from Under Review to Closed
hey!
I am closing the issue as there is a simple solution out of the box using traverse
condition: 'traverse(formValues, "checkbox-1") == 1'
see https://docs.typo3.org/c/typo3/cms-form/main/en-us/I/Concepts/Variants/Index.html
if you don't agree, feel free to contact me via slack!