Review main Merged

89085[BUGFIX] Respect leap years in timediff age calculation

Benjamin Franzke CR +2 V +2 Normal +133 −77 updated 04/24/25, 06:08

Commit message

Resort to DateTimeInterface::diff to take local timezone offsets and
leap years in age calculation into account.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
    • Benni Mack +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Stefan Bürk +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 11

Review log 3343

Show 1218 earlier messages
  1. Benjamin Franzke uploaded patch set 1 04/12/25, 16:15

  2. core-ci voted on patch set 1 V -1 04/12/25, 16:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77629

  3. Benjamin Franzke uploaded patch set 2 V -1 04/12/25, 16:56

  4. core-ci voted on patch set 2 V +1 04/12/25, 17:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77635

  5. Benjamin Franzke uploaded patch set 3 V +1 04/12/25, 19:23

  6. Benjamin Franzke uploaded patch set 4 04/12/25, 19:25

  7. Benjamin Franzke updated the commit message in patch set 5 04/12/25, 19:28

  8. core-ci voted on patch set 3 V -1 04/12/25, 19:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77642

  9. core-ci voted on patch set 4 V -1 04/12/25, 19:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77643

  10. core-ci voted on patch set 5 V -1 04/12/25, 19:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77645

  11. Benni Mack commented on patch set 5 04/12/25, 19:39

    Great (simple) change for such a long-standing issue. A few things: - AbstractFormElement->formatValue() has the same code as TcaRecordTitle -> should be adapted - BackendUtility::dateTimeAge() and BackendUtility::isRecordLocked() should also be adapted. - Scheduler->toolbarItemProvider as well - ExtensionManager/UpdateFromTerController can also benefit from the new formatAge() - Let's hard-require a string in formatAge() I also thought the adapted change was funny :)
  12. Benjamin Franzke uploaded patch set 6 V -1 04/12/25, 21:03

  13. core-ci voted on patch set 6 V +1 04/12/25, 21:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77652

  14. Benni Mack voted on patch set 6 CR +1 V +1 04/12/25, 22:21

  15. Oliver Hader commented on patch set 6 04/13/25, 08:06

    BackendUtility.php:946

    That index (and others of `$labelArr`) might not be available since `$labels` is variable...
  16. Oliver Hader voted on patch set 6 CR +1 04/13/25, 08:09

  17. Georg Ringer voted on patch set 6 CR +1 V +1 04/13/25, 20:48

  18. Benjamin Franzke commented on patch set 6 04/14/25, 05:32

    BackendUtility.php:946 Reply

    Yup, I thought about adding a RuntimeException, when the count after explode does not fit, but that'd fail if we previously "worked" despite an invalid number of units - 1) because the unit wasn't matched or 2) because too many units where supplied. Therefore I didn't want to risk throwing exceptions "just" to be pedantic in a bugfix release. What do you think? Keep as is?
  1. Oliver Hader commented on patch set 6 04/14/25, 09:23

    BackendUtility.php:946 Reply

    Fine for me...
  2. Oliver Hader commented on patch set 6 04/14/25, 11:10

    UpdateFromTerController.php:77

    I just tested that... before this patch it was `Time since last update 123 days`, with this patch it's `Time since last update -123 days`. Thus, I guess `$now->diff($lastUpdate)` should be inverted - probably at the other source locations as well.
  3. Benni Mack commented on patch set 6 V 0 CR -1 04/14/25, 12:57

    UpdateFromTerController.php:77 Reply

    Ha, yes. I did not test EM. That's still bug.
  4. Benni Mack uploaded patch set 7 CR +1 V +1 04/14/25, 13:22

  5. Benni Mack commented on patch set 7 CR +1 V +1 04/14/25, 13:22

    UpdateFromTerController.php:77 Reply

    Done
  6. core-ci voted on patch set 7 V +1 04/14/25, 13:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77700

  7. Andreas Kienast voted on patch set 7 CR +1 V +1 04/14/25, 13:40

  8. Benjamin Franzke commented on patch set 7 CR -1 04/14/25, 14:15

    UpdateFromTerController.php:77 Reply

    thanks, kinda ugly, this case basically misused/s the API, by providing positive seconds (which refers to a future timestamp) in order to calculate the label for a past time rendered as a future time (without a leading minus sing). That means the result will not be 100% accurate.. Maybe we'd better add a option to `formatAge` to skip the minus-sign in output, in order to be able to pass-in the correct `DateInterval`. So, although I'd love to just ignore this, I can't.. Will rework...
  9. Benjamin Franzke uploaded patch set 8 CR +1 V +1 04/14/25, 16:15

  10. Benjamin Franzke commented on patch set 8 04/14/25, 16:15

    UpdateFromTerController.php:77 Reply

    Done
  11. core-ci voted on patch set 8 V +1 04/14/25, 16:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77707

  12. Andreas Kienast commented on patch set 8 04/15/25, 05:05

    BackendUtility.php:942

    I wonder whether this patch deserves at least an Important.rst as the requirement for a new flag indicates a change of behavior.
  13. Oliver Hader commented on patch set 8 V -1 04/15/25, 07:26

    ContentObjectRenderer.php:1863

    After testing, this also does not seem to be correct: TypoScript: ``` page = PAGE page.10 = TEXT page.10.value = 1744701605 page.10.age = " Minuten | Stunden | Tage | Jahre | Minute | Stunde | Tag | Jahr" ``` * without the patch → `3 Minuten` (anything in the range or minutes, hours, days) * with the patch → `55 Jahre` (since the content is added up to the current timestamp - resulting in the difference being the interface since 1970)
  14. Benjamin Franzke commented on patch set 8 04/15/25, 10:06

    BackendUtility.php:942 Reply

    I don't see a need for any integrator having to act to this change. This flag is only used to apply the fix. Previously the seconds were passed in inverse because age calculation did not take concrete datetime into account, the age calculation was synchronous in either way. Now that it matters if we look 100 days back fix th

    ContentObjectRenderer.php:1863 Reply

    Ugh, thanks! I oversaw that when migrating to using formatAge directly. However, this let's me question the entire change, stdwrap.age is completely broken (inverse) The old code produced a `-` prefix for future dates instead of for past dates... ``` page = PAGE page.10 = TEXT page.10.value = 1744701605 page.10.age = " Minuten | Stunden | Tage | Jahre | Minute | Stunde | Tag | Jahr" page = PAGE page.20 = TEXT # timestamp of tomorrow page.20.value = 1744801605 page.20.age = " Minuten | Stunden | Tage | Jahre | Minute | Stunde | Tag | Jahr" ``` Currently produces ``` 3 Stunden -1 Tag ``` While it should produce: ``` -3 Stunden 1 Tag ``` It is basically non-fixable without being completely breaking.. :(
  15. Benjamin Franzke commented on patch set 8 04/15/25, 11:18

    BackendUtility.php:942 Reply

    comment was incomplete, and in light of https://review.typo3.org/c/Packages/TYPO3.CMS/+/89085/8/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php#1863 maybe not even tree anymore, forget about it ;)
  16. Benjamin Franzke uploaded patch set 9 V +1 04/15/25, 15:42

  17. Benjamin Franzke commented on patch set 9 04/15/25, 15:42

    BackendUtility.php:942 Reply

    Remove this parameter. DateInterval can be created absolute with `DateTime::diff(., true)`, we'll use that if an absolute format is desired.

    ContentObjectRenderer.php:1863 Reply

    Thanks, fixed by inverting the minus-prefix for calcAge to keep this as before.
  18. core-ci voted on patch set 9 V -1 04/15/25, 15:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77769

  19. Benjamin Franzke uploaded patch set 10 V -1 04/15/25, 15:51

  20. core-ci voted on patch set 10 V +1 04/15/25, 15:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77771

  21. Benni Mack voted on patch set 10 CR +1 V +1 04/22/25, 14:19

  22. Stefan Bürk voted on patch set 10 CR +1 04/23/25, 10:37

  23. Stefan Bürk voted on patch set 10 V +1 04/23/25, 11:58

  24. Benjamin Franzke voted on patch set 10 CR +2 V +2 04/24/25, 06:08

  25. Benjamin Franzke merged patch set 11 04/24/25, 06:08