Review 11.5 Merged

83082[BUGFIX] Prevent possible browser freezes in FormEditor

Benjamin Franzke CR +2 V +2 Easy +1 −7 updated 02/23/24, 09:45

Commit message

Using timestamps as array keys in form yaml configuration
can result in sparse [1] JavaScript arrays which contain
"empty slots".

Example yaml configuration:

  templateRootPaths:
    1708504268: 'EXT:example/Resources/Private/Emails/Templates'

This value is properly serialized into an object by PHP json_encode
(as it does not contain sequential integer keys starting at 0), but
the FormEditor data model produces arrays from numerical keys during
clone operations of such data sets and basically creates sparse arrays
like:

> const example = []
> example[1708504268] = 'EXT:example/Resources/Private/Emails/Templates'
> console.log(example)
[
  <1708504268 empty items>,
  'EXT:forms_extended/Resources/Private/Emails/Templates'
]

Some array-looping operations like Array.reduce() will loop through all
empty slots [1] and therefore preduce a lot of processing load
(1708504269 loops for the example above) that ultimately cause freezes.

The array to object copy operation is now replaced by a modern spread
operation that is defined to skip empty slots.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
  • Verified V +2 Done
    • Benjamin Franzke +2
    • core-ci +1 CI

Issues 1

Files 1

Review log 23

  1. Benjamin Franzke uploaded patch set 1 02/23/24, 09:26

  2. core-ci voted on patch set 1 V +1 02/23/24, 09:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53463

  3. Benjamin Franzke merged patch set 2 02/23/24, 09:45