Review main Merged

87144[BUGFIX] Streamline midnight vs null handling of time fields

Benjamin Franzke CR +2 V +2 Hard +822 −90 updated 12/06/24, 09:11

Commit message

* Treat 00:00(:00) as valid time for nullable native time fields
   (has been misinterpreted as an empty-value before)

 * Treat database value 0 as empty for non-nullable integer-based
   time fields (has not been differentiated from nullable fields before)

 * Treat an empty date-input value as NULL in DataHandler if the field
   is nullable (same result as unchecking the "Set value" checkbox)

 * Respect that native time fields are nullable by default since #97367,
   as they are generated as NULLable database fields by default.
   This recent new TcaSchema default is now honored in DataHandler
   and FormEngine in order to allow midnight – 00:00:00 – to be a valid
   value of nullable native TIME fields.

 * Reallow to use non-nullable native datetime fields by setting
   `'nullable' => false` explicitly in the TCA schema
   (to allow full backwards compat for fields that were not nullable in
   TYPO3 v12).

 * Add testcases for non-nullable date/datetime/time(sec) fields
   with – nowadays invalid – zero dates 0000-00-00
   (testcases rely on mariadb safe mode NO_ZERO_DATE to be disabled
   and are therefore tested in a seperate functional testcase)

Note: 00:00:00 handling for time fields has previously been fixed in v12
by #97216, but was effectively broken with #92900, which changed the
reset value to 00:00:00 (which is the db-native empty value) instead of
a value that is intended to be understood by formengine (which used to
be timestamp integers, but is ISO8601 nowadays).

Review

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

Issues 2

Files 28

Show 8 more files

Review log 1927

Show 12 earlier messages
  1. Benjamin Franzke uploaded patch set 1 11/21/24, 11:23

  2. core-ci voted on patch set 1 V -1 11/21/24, 11:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69928

  1. Benjamin Franzke uploaded patch set 2 V -1 11/27/24, 13:05

  2. core-ci voted on patch set 2 V -1 11/27/24, 13:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70255

  3. Benjamin Franzke uploaded patch set 3 V -1 11/27/24, 13:42

  4. core-ci voted on patch set 3 V -1 11/27/24, 13:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70256

  5. Benjamin Franzke uploaded patch set 4 V -1 11/27/24, 19:35

  6. core-ci voted on patch set 4 V +1 11/27/24, 19:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70278

  7. Benjamin Franzke uploaded patch set 5 V +1 11/27/24, 20:12

  8. core-ci voted on patch set 5 V +1 11/27/24, 20:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70280

  9. Benjamin Franzke updated the commit message in patch set 6 V +1 11/28/24, 22:01

  10. core-ci voted on patch set 6 V +1 11/28/24, 22:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70319

  11. Benjamin Franzke uploaded patch set 7 V +1 11/29/24, 07:32

  12. core-ci voted on patch set 7 V +1 11/29/24, 07:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70340

  13. Benni Mack commented on patch set 7 12/04/24, 11:13

    DataHandler.php:2167

    love this change...
  14. Benni Mack voted on patch set 7 CR +1 12/04/24, 11:26

  15. Benni Mack voted on patch set 7 V +1 12/04/24, 15:05

  16. Andreas Kienast commented on patch set 7 CR -1 12/05/24, 09:14

    on it
  17. Andreas Kienast commented on patch set 7 12/05/24, 09:30

    TcaSchema

    DatabaseRowDateTimeFields.php:68

    theory

    DataHandler.php:2172

    `$nativeDateTimeFieldEmptyValue` is potentially undefined, it's defined within `if (in_array($nativeDateTimeType, QueryHelper::getDateTimeTypes(), true)) {` only.

    DefaultTcaSchema.php:495

    `$formats` is unused

    DatetimeLegacyTest.php:96

    Why do we need the empty lines?
  18. Benjamin Franzke uploaded patch set 8 CR +1 V +1 12/05/24, 09:48

  19. Benjamin Franzke commented on patch set 8 12/05/24, 09:48

    Reply

    Done

    DatabaseRowDateTimeFields.php:68 Reply

    Done

    DataHandler.php:2172 Reply

    yea, well, statically seen it is always defined as the condition above checks for `isNativeDateTimeField`, therefore phpstan also did not complain. But better to initialize the value anyway, as done for reset before. Done.

    DefaultTcaSchema.php:495 Reply

    Ooops, left-over of a intermediate change. Thanks!

    DatetimeLegacyTest.php:96 Reply

    I applied the newlines because the fields are grouped like this in `DatetimeTest`. But not really needed, removed…
  20. core-ci voted on patch set 8 V +1 12/05/24, 09:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70636

  21. Andreas Kienast voted on patch set 8 CR +1 12/05/24, 10:18

  22. Andreas Kienast voted on patch set 8 V +1 12/05/24, 15:07

  23. Benni Mack voted on patch set 8 CR +1 V +1 12/06/24, 08:20

  24. Benjamin Franzke voted on patch set 8 CR +2 V +2 12/06/24, 09:05

  25. Benjamin Franzke merged patch set 9 12/06/24, 09:11