Review main Merged

93086[BUGFIX] Fix form editor crash when editing forms in multiple browser tabs

Josua Vogel CR +2 V +2 Normal +53 −27 updated 03/10/26, 03:54

Commit message

When editing two different forms simultaneously in separate browser
tabs, saving the first form after opening the second one caused an
exception:

  TYPO3\CMS\Form\Domain\Configuration\Exception\PropertyException
  Unauthorized modification of "prototype name" or "identifier".
  (#1528538322)

The root cause was that the form editor used a single global session
token (stored under the key `extFormProtectionSessionToken`) for HMAC
validation. Each time a form was opened for editing, `addHmacData()`
generated a new random token and overwrote the previous one. When
saving the first form, the HMAC validation failed because the token
had already been replaced by the second form's token.

The fix introduces per-form session tokens keyed by the form
persistence identifier:

- `addHmacData()` now accepts a `$formPersistenceIdentifier` parameter
  and stores the session token in a per-form token map under the
  session key `extFormProtectionSessionTokens`.
- The `_formPersistenceIdentifier` is embedded into the form definition
  payload sent to the client, so the TypeConverter can read it back
  when saving and look up the correct per-form token.
- `removeHmacData()` strips the `_formPersistenceIdentifier` before
  persisting, and the TypeConverter removes it before HMAC validation.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 6

Review log 2024

  1. Josua Vogel uploaded patch set 1 03/05/26, 15:34

  2. core-ci voted on patch set 1 V -1 03/05/26, 15:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97419

  3. Josua Vogel uploaded patch set 2 V -1 03/05/26, 16:41

  4. core-ci voted on patch set 2 V +1 03/05/26, 16:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97421

  5. Georg Ringer commented on patch set 2 V -1 03/06/26, 09:50

    still doesnt work for me: - opening form - duplicate tab - save in 1st, works - save in 2nd, works - save in 1st => crash with same error
  6. Georg Ringer commented on patch set 2 CR +1 V +1 03/06/26, 09:59

    works now for different forms, same form is still buggy but can also be a different issue
  7. Josua Vogel uploaded patch set 3 CR +1 V +1 03/06/26, 10:49

  8. Garvin Hicking commented on patch set 3 CR +1 V +1 03/06/26, 11:15

    Reply

    I would argue that in this case the error even helps, because then you don't save state over a stale representation of the same form.
  9. Garvin Hicking commented on patch set 3 CR 0 V 0 03/06/26, 11:18

    (mistakenly voted on the earlier variant of this - I'm not really sure we should "allow" multiple tabs of the actual form)
  10. core-ci voted on patch set 3 V +1 03/06/26, 11:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97484

  11. Josua Vogel commented on patch set 3 03/06/26, 11:29

    Reply

    Why not? 😊
  12. Garvin Hicking commented on patch set 3 03/06/26, 12:48

    Reply

    Let's say in one tab I added 10 form fields and saved. And then I get back to my other form tab. I remember "hey I want to change a field name here". I enter the field name, save -> and then (I think so, I haven't verified) the whole form will remove the 10 form fields from my other tab work and everything will go away. Since we don't version YAML files (yet *g*) that would be a bad loss of data, which the current exception would have prevented, no?
  13. Josua Vogel commented on patch set 3 03/07/26, 10:49

    Reply

    Good point, but I wonder if we should address this “error.” Some responsibility should also lie with the editor. I don't think throwing an exception, as is currently the case, is a good idea. With the prospect of versioning coming soon, we could consider merging this fix (maybe only main). Otherwise, we'll fix it again in a few months :)
  14. Garvin Hicking commented on patch set 3 03/07/26, 12:49

    Reply

    But where is the use case to allow editing the same form in multiple tabs? I only see danger and data loss here and find it a good thing it crashes now. It could crash with a distinct message. Personally I wouldn't go ahead with this witbout having form versions first.
  15. Garvin Hicking commented on patch set 3 03/07/26, 12:50

    Reply

    (Fixing different forms is totally fine by me, if you want to go back to that version of this patch)
  16. Josua Vogel commented on patch set 3 03/07/26, 13:21

    Reply

    Yes, data loss is a good point. Ultimately, however, this can also happen with normal content elements. The only additional point is that there is versioning. Another use case is, for example, when you have many tabs open, you forgot that you opened the form one Hour ago already - modify many parts, save, crashes, Frustration. I can wait with the fix until versioning is supported. Wouldnt go back to the previous patch for now, because I would Like to have it consistent with all other Content, which can be edited in different tabs
  17. Garvin Hicking commented on patch set 3 03/07/26, 13:43

    Reply

    oK but that wouls leave 13.4 unfixed for editing multiple forms. I think that is far more important than being able to edit the same form in multiple tabs. We should fix that IMO.
  18. Josua Vogel uploaded patch set 4 V +1 03/08/26, 18:18

  19. Josua Vogel commented on patch set 4 03/08/26, 18:19

    Reply

    Done
  20. core-ci voted on patch set 4 V +1 03/08/26, 18:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97572

  21. Garvin Hicking voted on patch set 4 CR +1 V +1 03/09/26, 13:09

  22. Georg Ringer voted on patch set 4 CR +1 V +1 03/10/26, 03:54

  23. Georg Ringer voted on patch set 4 CR +2 V +2 03/10/26, 03:54

  24. Georg Ringer merged patch set 5 03/10/26, 03:54