Review main Merged

77895[BUGFIX] Add correct diff source values to translated record

Markus Hofmann CR +2 V +2 Normal +114 −24 updated 02/25/23, 12:15

Commit message

This change ensures that the original language record diff source
(usually in the field l10n_diffsource as configured by
transOrigDiffSourceField) is set correctly as soon as a localized
record is created.

To guard this, an additional test for pages is added, and several
DataHandler tests are adjusted.

TYPO3 displays the source language value of a field for a translated
record. This information field can display a diff, if the source record
value was changed. To accomplish this a shadow copy of localizable
fields from the source language record is saved in the configurable
language diff source field.

Localization of a record creates a new record, adding the values of
localizable fields value with a prefix and setting needed system fields
like parent record id, language id and so on. This is updated if a
localized field is changed in the localized language.

`\TYPO3\CMS\Core\DataHandling\DataHandler` as the main actor in the
backend is responsible for maintaining this source diff field along
with other tasks. Due to an oversight, the source language record data
was not set during record localization. Because of this, the field
source display did not work until the localized record was saved again.
This probably went undetected because in normal editorial work the
record would be changed straight away.

Extension authors using DataHandler hooks can influence which data is
written, for example using translation tools and databases to localize
records automatically during the translation process. Therefore, it is
not really mandatory to change the value afterwards. In the past, that
practice lead to a broken and invalid source diff field. The issue
existed for pages and other records in the same way.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Sybille Peters +1
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Sybille Peters +1
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 12

Review log 2434

Show 59 earlier messages
  1. Markus Hofmann uploaded patch set 1 02/19/23, 10:11

  2. core-ci voted on patch set 1 V -1 02/19/23, 10:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37867

  3. Markus Hofmann uploaded patch set 2 V -1 02/19/23, 10:38

  4. core-ci voted on patch set 2 V -1 02/19/23, 10:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37869

  5. Markus Hofmann uploaded patch set 3 02/19/23, 14:05

    Copied Votes: * Verified-1 (copy condition: "changekind:NO_CHANGE")
  6. Markus Hofmann uploaded patch set 4 V -1 02/19/23, 14:15

  7. core-ci voted on patch set 3 V -1 02/19/23, 14:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37879

  8. core-ci voted on patch set 4 V +1 02/19/23, 14:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37880

  9. Stefan Bürk commented on patch set 4 CR -1 02/21/23, 18:11

    on it ...
  1. Stefan Bürk uploaded patch set 5 CR -1 V +1 02/23/23, 08:00

  2. core-ci voted on patch set 5 V +1 02/23/23, 08:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37994

  3. Stefan Bürk voted on patch set 5 V +1 CR +1 02/23/23, 08:08

  4. Stefan Bürk updated the commit message in patch set 6 CR +1 V +1 02/23/23, 09:22

  5. Stefan Bürk voted on patch set 6 V +1 CR +1 02/23/23, 09:22

  6. core-ci voted on patch set 6 V +1 02/23/23, 09:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37995

  7. Nikita Hovratov uploaded patch set 7 CR +1 V +1 02/24/23, 20:13

  8. core-ci voted on patch set 7 V +1 02/24/23, 20:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38069

  9. Nikita Hovratov voted on patch set 7 V +1 CR +1 02/24/23, 20:34

  10. Sybille Peters commented on patch set 7 02/25/23, 08:54

    I left some comments on commit msg. Will review and test next. I am a bit nitpicky about text. Don't worry about it. These are mere suggestions (can be accepted or rejected), will not leave -1 for this. Fun fact: I translated entire commit message with DeepL. (I did not do this initially and did not use the result, except for the title, but the DeepL translation is quite good). Translate original commit msg to DE, then press the <-- ---> (Swap source language with target language)
    > Ensure that diffSource values of translation is directly added My suggestion: "Add DiffSource values to translated record on creation" Reason: this emphasizes that the problem occurs when a new record is created. DeepL suggestion: "Ensure that diffSource values are added directly to the translation." This reads a little more smoothly than original title. Unfortunately it is longer, so I discarded it.
    Would probably use transOrigDiffSourceField (by convention usually l10n_diffsource) somewhere in the commit message to make it clear what field we are talking about.
    suggestion: remove "basically" and "eventually" (it seems to me, is not strictly necessary and does not improve readability).
    This part is difficult to read and understand for me, especially "eventually with a prefix and setting needed system fields" and "localizable fields value" (the value of localizable fields or what is meant here?)
    > "This has been undiscovered most likely" suggestion: "This probably went undetected because" (is shorter, also if using "undiscovered" should probably be "had remained undiscovered")
    > and no one is expecting that the value of the source language record changed in the meantime. would remove that entire part
    Maybe lead with this (start the commit msg with this). Because of long commit msg we might want to lead with short summary what the patch does.
    Instead of "is used directly" maybe write "is used as soon as a new localized language record is created". The problem is when the new record is created, not when an existing one is opened. The "directly" does not make that clear for me, also "initially" might be better.
  11. Sybille Peters updated the commit message in patch set 8 CR +1 V +1 02/25/23, 09:40

  12. Sybille Peters commented on patch set 8 02/25/23, 09:42

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done

    Reply

    Done
  13. Sybille Peters updated the commit message in patch set 9 02/25/23, 09:43

  14. core-ci voted on patch set 8 V +1 02/25/23, 09:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38080

  15. core-ci voted on patch set 9 V +1 02/25/23, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38081

  16. Sybille Peters commented on patch set 9 02/25/23, 10:25

    DataHandler.php:1331

    This field will also be filled if a new record was created in the default language (sys_language_uid=0) with no corresponding source language record (l10n_parent = 0). Is it really necessary to fill it in that case or should it just be an empty string? (apart from that, patch works as expected +1).
  17. Sybille Peters voted on patch set 9 CR -1 02/25/23, 11:41

  18. Stefan Bürk uploaded patch set 10 CR -1 V +1 02/25/23, 11:46

  19. core-ci voted on patch set 10 V +1 02/25/23, 11:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38085

  20. Stefan Bürk commented on patch set 10 02/25/23, 11:57

    DataHandler.php:1331 Reply

    Should be covered now.
  21. Sybille Peters commented on patch set 10 V +1 CR +1 02/25/23, 12:03

    😊
  22. Nikita Hovratov voted on patch set 10 V +1 CR +1 02/25/23, 12:06

  23. Stefan Bürk commented on patch set 10 02/25/23, 12:14

    DataHandler.php:1331 Reply

    Done
  24. Stefan Bürk voted on patch set 10 V +2 CR +2 02/25/23, 12:15

  25. Stefan Bürk merged patch set 11 02/25/23, 12:15