Review main Abandoned

82494[BUGFIX] Keep 'crdate' value of records when importing T3D

Garvin Hicking CR 0 V 0 Normal +189 −2 updated 01/25/24, 10:42

Commit message

If T3D data is imported with records or pages that contain a
"tstamp" and "crdate" property, the import will overwrite
their values with the current timestamp.

The "tstamp" value is fine to be overwritten with the import
date, because it is a modification of an existing record
when being inserted.

However, the "crdate" value should not be overwritten, to
preserve original data. This is fixed with this patch, by
letting the DataHandler recognize the import-context and
using the original input "crdata" instead of the current
timestamp.

Tests are added to ensure this behavior.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 4

Review log 2532

Show 67 earlier messages
  1. Garvin Hicking uploaded patch set 1 01/17/24, 11:11

  2. core-ci voted on patch set 1 V +1 01/17/24, 11:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51677

  3. Oliver Klee commented on patch set 1 01/17/24, 12:05

    Can we cover this with a test?
  4. Garvin Hicking uploaded patch set 2 V +1 01/17/24, 13:03

    Yes we can
  5. Oliver Klee commented on patch set 2 CR -1 01/17/24, 13:04

    PagesAndTtContentWithCrdate.php:25

    The class name needs to end with `Test` for PHPUnit to recognize it.
  6. Garvin Hicking commented on patch set 2 01/17/24, 13:04

    Reply

    Yes. I at first didn't want to do the work before some feedback from Christian. But I figure having a test will make him look at it with a better feeling, so I added some, hope they are sufficient. If not, please let me know what I can improve. I used the existing test and fixtures as a baseline.
  7. Garvin Hicking uploaded patch set 3 CR -1 01/17/24, 13:05

    Rename test
  1. Garvin Hicking commented on patch set 3 01/17/24, 13:06

    PagesAndTtContentWithCrdate.php:25 Reply

    Done
  2. core-ci voted on patch set 2 V -1 01/17/24, 13:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51684

  3. Garvin Hicking uploaded patch set 4 01/17/24, 13:11

    CGL
  4. core-ci voted on patch set 3 V -1 01/17/24, 13:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51685

  5. core-ci voted on patch set 4 V +1 01/17/24, 13:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51686

  6. Oliver Klee voted on patch set 4 V +1 01/17/24, 13:18

  7. Oliver Klee commented on patch set 4 01/17/24, 13:21

    DataHandler.php:1090

    Also, what should be the behavior if the crdate is set, but is `null` or `0`?

    DataHandler.php:1090

    As `$this->isImporting` is already always a boolean and cannot have any truthy non-boolean values, we can shorten this to: ```php if ($this->isImporting && isset($incomingFieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']])) { ```
  8. Garvin Hicking uploaded patch set 5 V +1 01/17/24, 13:33

    Shorten boolean check
  9. Garvin Hicking commented on patch set 5 01/17/24, 13:33

    DataHandler.php:1090 Reply

    The XML/T3D generated does not know "null", and since crdate/tstamp shouldn't really contain "0", in this case IMO a current timestamp is useful.

    DataHandler.php:1090 Reply

    Done
  10. core-ci voted on patch set 5 V +1 01/17/24, 13:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51687

  11. Oliver Klee voted on patch set 5 V +1 01/17/24, 13:50

  12. Oliver Klee voted on patch set 5 CR +1 01/17/24, 13:51

  13. Oli Bartsch commented on patch set 5 01/17/24, 15:30

    DataHandler.php:1088

    While already on it, could we merge the two if's?
  14. Garvin Hicking uploaded patch set 6 CR +1 V +1 01/17/24, 16:04

    Merge one level of IF
  15. core-ci voted on patch set 6 V +1 01/17/24, 16:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51700

  16. Garvin Hicking commented on patch set 6 01/17/24, 16:29

    DataHandler.php:1088 Reply

    Yes, sure. Usually with DataHandler I try to surgically only do the minimum changes, but in this case it should work out just fine :-)
  17. Stefan Bürk commented on patch set 6 01/17/24, 18:15

    DataHandler.php:1090 Reply

    Generally spoken, we could think about not relating this to `$this->isImporting` and instead say in a two step condition * 1: $status === new && TCA has crdate field * 2: use incomingFieldArray[crdate-field] if valid otherwise set EXEC_TIME That allows to also set normal data using datahandler without needing to set it into import mode. I had a couple of cases and project (just remembering it) where a explicit creation date was required to be set (and I had to do a update after the creation to override it again). What do you think ? Note: tsstamp should always be updated if that field exists.
  18. Garvin Hicking commented on patch set 6 01/17/24, 19:13

    DataHandler.php:1090 Reply

    I was too afraid of changing FormEngine related data handling and what it could impact. Would like some feedback from more FormEngine-veterans, and this kind of feels like a possible BC then?! I don't know if any extensions could rely on the fact that crdata for "new" is always set to the current time... (I agree on tstamp, it should never be kept, and this patch doesn't change jt)
  19. Stefan Bürk commented on patch set 6 01/18/24, 08:22

    DataHandler.php:1090 Reply

    First, DataHandler is not FormEngine only. In fact, is communicated to the way to do operations instead of doing plain stuff (at least in BE/CLI context). I would postulate that if your explicitly provide a valid value for `crdate` than you expect to have it in the database and therefore taking this as a bugfix (bugfix are always a change in behaviour in for someone eventually breaking taking a bug as a feature). But I'm fine to postpone that and doing it as a own patch in a couple of days/weeks.
  20. Garvin Hicking commented on patch set 6 01/18/24, 10:56

    DataHandler.php:1090 Reply

    Alright! My FormEngine example was just meant to indicate that I wanted to restrict this chane to the Import only because I can not really oversee the impact it could have on all other casess, so it's good you broadened the scope even more. I'll leave this one open for a few more days to see if someone wants to chime in with thoughts on it.
  21. Garvin Hicking commented on patch set 6 01/20/24, 09:46

    DataHandler.php:1090 Reply

    see: https://typo3.slack.com/archives/C03AM9R17/p1705575487463589 This patch will thus likely be abandoned.
  22. Garvin Hicking rebased onto patch set 7 V +1 01/24/24, 12:45

  23. core-ci voted on patch set 7 V +1 01/24/24, 12:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52077

  24. Stefan Bürk commented on patch set 7 01/25/24, 10:42

    DataHandler.php:1090 Reply

    Will abandon this patch as crdate and tsstamp should be stay core controlled.
  25. Stefan Bürk abandoned the change 01/25/24, 10:42

    Will abandon this patch as crdate and tsstamp should be stay core controlled.