Project

General

Profile

Actions

Bug #91236

open

Numeric array keys are not merged correctly in YAML import

Added by Jan Delius almost 4 years ago. Updated over 3 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2020-04-29
Due date:
% Done:

0%

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

Description

If in a YAML file another one is included by imports, numeric array keys are reset, if they are already described elsewhere in the current file or another import.

This functionality is important for the Form Framework to be able to split its own finishers into several YAML files. There is a way around this in ext:form (simply do not import the values separately, but define them centered somewhere else), but this does not allow a clean separation.

Example:
If you want to insert a value into file A.yaml under TYPO3.CMS.Form.prototypes.standard.formElementsDefinition.Form.formEditor.editors.900.selectOptions, this works without any problems. If you now add another value to file B.yaml, the values do not appear at the end under 900.selectOptions, but under 0.selectOptions and 1.selectOptions.

This only happens when one or both of these files are imported into a YAML file. If the files are loaded independently via TypoScript, it works without problems.

Example A.yaml:

TYPO3:
  CMS:
    Form:
      test:
        20:
          a: b

Example B.yaml:

TYPO3:
  CMS:
    Form:
      test:
        20:
          e: f
        21:
          c: d

My FormSetup.yaml:

imports:
  - { resource: "./A.yaml" }
  - { resource: "./B.yaml" }

This results in the following result:

TYPO3:
  CMS:
    Form:
      test:
        0:
          e: f
        1:
          c: d
        2:
          a: b

Which it should be:

TYPO3:
  CMS:
    Form:
      test:
        20:
          a: b
          e: f
        21:
          c: d


Related issues 1 (1 open0 closed)

Has duplicate TYPO3 Core - Bug #94729: Method ArrayUtility::replaceAndAppendScalarValuesRecursive re-numbers associative arrays with non-consecutively numbered integer-only keysUnder Review2021-08-05

Actions
Actions #1

Updated by Jigal van Hemert over 3 years ago

In TypoScript numerical keys are kept as they are. This is documented to allow items to be inserted between existing items.
Combining yaml files uses logic for numerical keys that is similar to the PHP function array_merge. This also explains why the numerical keys are renumbered.

The hard part in this regard is that lists in yaml usually don't use any keys, but when converted to PHP arrays numerical keys are automatically introduced (PHP arrays must have a numerical or string key). The behaviour when importing yaml files is correct from the point of view of a basic yaml list.
The Forms configuration uses numerical keys like TypoScript does.
After the data is converted to PHP arrays it's impossible to see is it was automatically numbered or not.

Actions #2

Updated by Stephan Jorek over 2 years ago

  • Related to Bug #94729: Method ArrayUtility::replaceAndAppendScalarValuesRecursive re-numbers associative arrays with non-consecutively numbered integer-only keys added
Actions #3

Updated by Stephan Jorek over 2 years ago

  • Related to deleted (Bug #94729: Method ArrayUtility::replaceAndAppendScalarValuesRecursive re-numbers associative arrays with non-consecutively numbered integer-only keys)
Actions #4

Updated by Stephan Jorek over 2 years ago

  • Has duplicate Bug #94729: Method ArrayUtility::replaceAndAppendScalarValuesRecursive re-numbers associative arrays with non-consecutively numbered integer-only keys added
Actions

Also available in: Atom PDF