Review main Merged

88834[TASK] Add internal BeforeRemoveNonCopyableFieldsEvent to DataHandler

Torben Hansen CR +2 V +2 Hard +279 −7 updated 04/12/26, 10:55

Commit message

A PSR-14 event BeforeRemoveNonCopyableFieldsEvent is added
within DataHandler to allow modification of the list of
non-copyable fields during copy and localization processes.

This event is explicitly marked as `@internal`. It targets
specific edge cases where developers need to prevent the
copying of certain fields dynamically. Because improper
use of this event can easily lead to data inconsistencies
or broken records, it is intended only for experienced
developers who understand the implications of
DataHandler's field processing.

As an internal API, this event is provided "as-is" and may
change or be removed in future versions without the usual
deprecation period.

The event is dispatched in:

- DataHandler::copyRecord()
- DataHandler::copyRecord_raw()
- DataHandler::localize()

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • Stefan Bürk +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Benni Mack +2
    • Oliver Klee +1
    • Garvin Hicking +1
    • Stefan Bürk +1
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 10

Review log 6382

Show 4357 earlier messages
  1. Torben Hansen uploaded patch set 1 03/29/25, 13:15

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

  3. Torben Hansen commented on patch set 1 CR -1 03/29/25, 18:03

    On it
  4. Torben Hansen uploaded patch set 2 CR -1 V +1 03/30/25, 10:28

  5. Torben Hansen uploaded patch set 3 03/30/25, 10:31

  6. Georg Ringer voted on patch set 3 CR +1 V +1 03/30/25, 18:34

  7. Garvin Hicking commented on patch set 3 CR +1 V +1 03/30/25, 19:59

    Maybe we could adjust this to the
  8. Garvin Hicking commented on patch set 3 03/31/25, 06:55

    Reply

    Don't mind this comment, its obsolete
  9. Benni Mack commented on patch set 3 CR -2 04/09/25, 21:13

    please wait for this, discussing with Torben
  10. Oli Bartsch commented on patch set 3 05/23/25, 10:24

    Reply

    @benni@typo3.org @derhansen@gmail.com Have you already talked about this?
  11. Torben Hansen commented on patch set 3 05/23/25, 11:01

    Reply

    @bo@cedev.de Yes,@benni@typo3.org wants to discuss the patch with @lolli@schwarzbu.ch
  12. Benni Mack uploaded patch set 4 CR +1 V +1 08/15/25, 15:29

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  13. Benni Mack commented on patch set 4 CR 0 08/15/25, 15:32

    Reply

    Done
  14. core-ci voted on patch set 4 V -1 08/15/25, 15:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83468

  15. Stefan Bürk commented on patch set 4 08/16/25, 22:22

    DataHandler.php:3472

    Do we really want to allow that "defaultExcludeFields" are removable ? If not, that should be protected because this is possible with this event, accidently or intentionally.
  16. Benni Mack commented on patch set 4 08/17/25, 06:13

    DataHandler.php:3472 Reply

    I changed this intentionally. I don’t know any use case but instead of adding another event later-on let’s make this one more powerful. that was my intention. but as with all events: you need to know what you’re doing
  17. Oli Bartsch commented on patch set 4 08/17/25, 08:02

    DataHandler.php:3459

    Could we please get some tests for this event, ensuring it is called, processed and modified values influence the further program? You can search for `*EventIsCalled` for similar tests.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:14

    One of the main goals of PSR-14 Events is to add connivence for the developer and to abstract the actual logic in the dispatching code. This also means, using better / more speaking naming for the event methods. I've therefore proposed some changes to the current event implementation.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:30

    getDestinationPageId()

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:31

    isMainRecordToCopy(): Indicates whether this is the main record to copy, no relation or child.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:32

    getLanguageId()

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:33

    Indicates whether localization requests should be ignored.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:36

    We might should add `setOverrideValue(string $field, mixed $value)` to set just a single field. We might even think about an `unsetOverrideValue(string $field)`.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:37

    "Returns the current list of excluded fields." <= They should and are already provided as array values AFAICS.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:38

    array $fields. Additionally I like to also have a `setExcludeField(string $field)` to add just a single field. We might even think about an `unsetExcludeField(string $field)` for convenience.
  18. Torben Hansen uploaded patch set 5 V -1 08/22/25, 05:22

  19. Torben Hansen commented on patch set 5 08/22/25, 05:22

    DataHandler.php:3459 Reply

    I added some functional tests to test the DataHandler copy process. The tests cover usage of the new PSR-14 event, where `excludeFields` and `overrideValues` are modified.

    DataHandler.php:3472 Reply

    Agree with Benni.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:14 Reply

    Done

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:30 Reply

    Done

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:31 Reply

    Done

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:32 Reply

    Done

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:33 Reply

    Done

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:36 Reply

    I think the existing methods (`getOverrideValues()`and `setOverrideValues()`) are sufficient. Developers can use them to handle single fields if needed, so I don’t see the necessity for additional convenience methods.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:37 Reply

    Yes, this is an array already.

    Feature-106456-NewPSR-14BeforeCopyRecordFieldProcessingEvent.rst:38 Reply

    Type has been changed. I think the existing methods (`getExcludeFields()`and `setExcludeFields()`) are sufficient.
  20. core-ci voted on patch set 5 V -1 08/22/25, 05:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83736

  21. Torben Hansen rebased onto patch set 6 V -1 08/22/25, 06:27

  22. core-ci voted on patch set 6 V -1 08/22/25, 06:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83737

  23. Torben Hansen uploaded patch set 7 V -1 08/22/25, 06:46

  24. core-ci voted on patch set 7 V -1 08/22/25, 06:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83739

  25. Torben Hansen uploaded patch set 8 V -1 08/22/25, 06:57

  26. core-ci voted on patch set 8 V -1 08/22/25, 07:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83740

  27. Torben Hansen uploaded patch set 9 V -1 08/22/25, 07:09

  28. core-ci voted on patch set 9 V -1 08/22/25, 07:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83742

  29. Torben Hansen uploaded patch set 10 V -1 08/22/25, 07:34

  30. core-ci voted on patch set 10 V -1 08/22/25, 07:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83744

  31. Torben Hansen uploaded patch set 11 V -1 08/22/25, 08:23

  32. core-ci voted on patch set 11 V +1 08/22/25, 08:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83747

  33. Georg Ringer voted on patch set 11 CR +1 V +1 09/08/25, 05:21

  34. Simon Schaufelberger voted on patch set 11 CR +1 V +1 09/19/25, 10:10

  35. Jörg Bösche voted on patch set 11 CR +1 09/19/25, 11:28

  36. Oli Bartsch commented on patch set 11 09/19/25, 14:00

    Not blocking, but I’m not quite convinced adding more events to DataHandler is a good idea at this point. We still lack necessary tests, and I think @lolli@schwarzbu.ch is still in cleanup mode ;). I’m also currently evaluating how we could introduce a facade for DataHandler to enable proper command-based write operations. That said, if this brings significant benefit, please go ahead and merge — I have no objections regarding the code or functionality itself.
  37. Benni Mack commented on patch set 11 10/15/25, 14:46

    Reply

    @bo@cedev.de I chatted with Christian about this change, and we agreed this is OK to do now.
  38. Oli Bartsch commented on patch set 11 10/15/25, 15:23

    Reply

    Acknowledged
  39. Christian Kuhn commented on patch set 11 10/31/25, 01:20

    Reply

    really? i don't recall and tend to 'better not'. is it ok to chat about this again? sorry for the mess ...
  40. Benni Mack commented on patch set 11 12/08/25, 12:43

    DataHandler.php:3470

    OK. Lolli and me analyzed the problem again: - So we want to exclude the fields of inline children that are not localizable, correct? - So we want to do this ONLY on localize and not on copy, right? Because with Schema API we could do this now: We loop over all fields when doing translate/localize and not on a regular copy. We check if the field is inline and not localizable, if it isn't localizable - we add it to the list of excluded fields.
  41. Torben Hansen commented on patch set 11 12/08/25, 12:54

    DataHandler.php:3470 Reply

    No, not exactly. This patch is mainly for the copy operation, but also for the localize. Basically, I want to prevent a certain field from being copied/localized in DataHandler. We had this option back in v9 (`setToDefaultOnCopy`) and I still think, it is a valid usecase to control, if a field should be excluded in a copy/localize scenario (e.g. record with "events" and inline records "event registrations" -> do not copy registrations on event copy). Therefore I think it might be useful for developers, to be able to control `$excludeFields` or `$overrideValues`.
  42. Torben Hansen uploaded patch set 12 CR +1 V +1 01/13/26, 10:27

  43. core-ci voted on patch set 12 V -1 01/13/26, 10:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93329

  44. Torben Hansen uploaded patch set 13 V -1 01/16/26, 18:30

  45. core-ci voted on patch set 13 V +1 01/16/26, 18:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93625

  46. Philipp Kitzberger commented on patch set 13 CR +1 V +1 01/18/26, 15:42

    Works like a charm! Thanks for implementing that feature, @derhansen@gmail.com
  47. Torben Hansen uploaded patch set 14 CR +1 V +1 02/14/26, 10:51

  48. core-ci voted on patch set 14 V +1 02/14/26, 11:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95883

  49. Philipp Kitzberger voted on patch set 14 CR +1 V +1 02/15/26, 13:18

  50. Torben Hansen commented on patch set 14 02/20/26, 09:58

    Note: I will adapt/rework the patch, when https://review.typo3.org/c/Packages/TYPO3.CMS/+/92881 is merged.
  51. Torben Hansen uploaded patch set 15 CR +1 V +1 02/24/26, 17:51

  52. Torben Hansen marked it work in progress 02/24/26, 17:52

  53. core-ci voted on patch set 15 V +1 02/24/26, 18:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96773

  54. Torben Hansen uploaded patch set 16 V +1 03/11/26, 17:28

  55. Torben Hansen marked it ready for review 03/11/26, 17:48

  56. Torben Hansen commented on patch set 16 03/11/26, 17:49

    Reply

    Done

    Reply

    Done

    DataHandler.php:3470 Reply

    Patch adapted as discussed.
  57. core-ci voted on patch set 16 V +1 03/11/26, 18:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97771

  1. Simon Schaufelberger uploaded patch set 17 V +1 03/11/26, 18:41

  2. core-ci voted on patch set 17 V +1 03/11/26, 18:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97772

  3. Garvin Hicking voted on patch set 17 CR +1 V +1 03/29/26, 10:32

  4. Philipp Kitzberger commented on patch set 17 03/29/26, 15:57

    The example implementation in the .rst file indicates that getFunctionName returns just the function name, while in reality it's class+function! Which one is it?
  5. Torben Hansen uploaded patch set 18 CR +1 V +1 03/29/26, 17:34

  6. Torben Hansen commented on patch set 18 03/29/26, 17:35

    Reply

    Good spot 👍. I changed this to `__FUNCTION__`, so now only the function name is used.
  7. core-ci voted on patch set 18 V -1 03/29/26, 17:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/98990

  8. core-ci commented on patch set 18 03/29/26, 17:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/98990

  9. Torben Hansen updated the commit message in patch set 19 V -1 03/29/26, 18:05

  10. core-ci voted on patch set 19 V +1 03/29/26, 18:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/98992

  11. Garvin Hicking voted on patch set 19 CR +1 V +1 03/29/26, 18:33

  12. Simon Schaufelberger voted on patch set 19 CR +1 V +1 03/29/26, 19:12

  13. Philipp Kitzberger voted on patch set 19 CR +1 V +1 03/30/26, 09:10

  14. Benni Mack commented on patch set 19 CR -2 03/30/26, 13:30

    I still need to verify this again with https://review.typo3.org/c/Packages/TYPO3.CMS/+/88837 Will block this change for the time being and bring it in as exceptional feature after Feature Freeze once the details are sorted out.
  15. Christian Kuhn commented on patch set 19 04/10/26, 18:37

    Reply

    alignment with torben: despite https://review.typo3.org/c/Packages/TYPO3.CMS/+/88837 being sorted out now, we'll take the event (slightly changed) since there is especially a copy scenario that we can't circumvent currently. we'll push here again and will mark the event @internal since it will be brittle and only for special cases and for devs who know exactly what they are doing. torben will push here soon and i'll then pick up as well.
  16. Torben Hansen uploaded patch set 20 CR +1 V +1 04/12/26, 05:26

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  17. Torben Hansen commented on patch set 20 04/12/26, 05:31

    Reply

    Changes have been implemented as discussed and the event is not declared as `@internal`. Commit message has been adapted from [FEATURE] to [TASK], because the new event is not public API and should not be promoted in docs.
  18. core-ci voted on patch set 20 V +1 04/12/26, 06:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100010

  19. Oliver Klee voted on patch set 20 V +1 04/12/26, 06:55

  20. Benni Mack voted on patch set 20 CR +1 04/12/26, 08:45

  21. Garvin Hicking voted on patch set 20 CR +1 V +1 04/12/26, 08:55

  22. Christian Kuhn voted on patch set 20 CR +1 V +1 04/12/26, 10:08

  23. Stefan Bürk voted on patch set 20 CR +1 V +1 04/12/26, 10:11

  24. Benni Mack voted on patch set 20 CR +2 V +2 04/12/26, 10:55

  25. Benni Mack merged patch set 21 04/12/26, 10:55