Review main Merged

81702[BUGFIX] Fix PHP error in FormEditor property preparation

TYPO3com CR +2 V +2 Easy +5 −1 updated 11/20/23, 22:01

Commit message

This change fixes the error

`array_key_exists(): Argument #1 ($key) must be a valid array offset
type`

This error occurs, for example, when a SaveToDatabase finisher is
configured to map a form field named "type":

  finishers:
    -
      identifier: SaveToDatabase
      options:
        -
          table: tx_mytable
          elements:
            type:
              mapOnDatabaseColumn: foo

The FormEditor invokes
transformMultiValuePropertiesForFormEditor($definition, 'type', $types)
with the intent to transform all structures that contain a
`type: {someDefinedType}` child-entry to a slightly different format.
It does this recursively for the entire form configuration, and
failed for the finisher cases mentioned above.

As `type` has an array value in this case:

  ['mapOnDatabaseColumn' => 'foo']

it can not be used as `$key` argument for `array_key_exists`.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oliver Klee +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1622

  1. TYPO3com uploaded patch set 1 11/07/23, 13:18

  2. core-ci voted on patch set 1 V +1 11/07/23, 13:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48689

  3. Benni Mack updated the commit message in patch set 2 V +1 11/07/23, 14:11

  4. Oliver Klee commented on patch set 1 11/07/23, 14:11

    FormEditorController.php:574

    Are valid identifiers guaranteed to be strings, or could they also be ints?
  5. core-ci voted on patch set 2 V +1 11/07/23, 14:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48690

  6. Benjamin Franzke uploaded patch set 3 V +1 11/10/23, 06:34

  7. Benjamin Franzke commented on patch set 3 11/10/23, 06:34

    FormEditorController.php:574 Reply

    They are, as multiValueProperties is a list of strings. I've added respective annotations.
  8. Benjamin Franzke voted on patch set 3 V +1 CR +1 11/10/23, 06:34

  9. Benjamin Franzke commented on patch set 3 V 0 CR -1 11/10/23, 06:39

    sorry, missed something. on it.
  10. Benjamin Franzke uploaded patch set 4 CR -1 11/10/23, 06:44

  11. Benjamin Franzke commented on patch set 4 11/10/23, 06:44

    Reply

    Done.

    FormEditorController.php:574 Reply

    A string-based map to a list of strings to be correct.
  12. Benjamin Franzke voted on patch set 4 V +1 CR +1 11/10/23, 06:44

  13. core-ci voted on patch set 3 V -1 11/10/23, 06:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48781

  14. core-ci voted on patch set 4 V +1 11/10/23, 06:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48782

  15. Benjamin Franzke commented on patch set 4 11/10/23, 08:19

    BTW, I just noticed we got more problems with `type` as element identifier, since the default value of the rendered element is taken from `FormRuntime->getType()` which means it is always `'Form'` 😕 but that's a broader problem (design issue of EXT:form) which will need to be fixed separately.
  16. Oliver Klee voted on patch set 4 CR +1 11/10/23, 08:29

  17. Stefan Bürk updated the commit message in patch set 5 CR +1 V +1 11/19/23, 21:31

  18. Stefan Bürk voted on patch set 5 V +1 CR +1 11/19/23, 21:31

  19. core-ci voted on patch set 5 V +1 11/19/23, 21:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49107

  20. Oliver Klee voted on patch set 5 CR +1 11/19/23, 21:55

  21. Benjamin Franzke voted on patch set 5 V +2 CR +2 11/19/23, 22:42

  22. Benjamin Franzke merged patch set 6 11/20/23, 22:01