Review main Merged

76912[FEATURE] Add minimum age option to cleanup:deletedrecords cli command

Christoph Lehmann CR +2 V +2 Normal +85 −28 updated 02/16/23, 19:24

Commit message

Using the cli command `cleanup:deletedrecords` to clean up the database
periodically is not really possible with an installed EXT:recycler,
because all records marked for deletion are deleted immediately and thus
the recycler seems less useful.

The new option `--min-age` added to the `cleanup:deletedrecords` cli
command allows to define a minimum age of X days a record needs to be
marked as deleted before it gets deleted.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Anja Leichsenring +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Anja Leichsenring +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2537

Show 812 earlier messages
  1. Christoph Lehmann uploaded patch set 1 12/02/22, 22:01

  2. Christoph Lehmann uploaded patch set 2 12/02/22, 22:06

  3. core-ci voted on patch set 1 V -1 12/02/22, 22:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34579

  4. Christoph Lehmann uploaded patch set 3 12/02/22, 22:13

  5. Christoph Lehmann commented on patch set 3 12/02/22, 22:13

    The change is ready for review
  6. core-ci voted on patch set 2 V -1 12/02/22, 22:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34580

  7. core-ci voted on patch set 3 V +1 12/02/22, 22:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34581

  8. Chris Müller commented on patch set 3 12/03/22, 06:20

    Feature-99258-AddMinimumAgeOptionToRecordDeletionCommand.rst:25

    I suggest to use only "bin/typo3" to avoid confusion with legacy and composer installations.

    Feature-99258-AddMinimumAgeOptionToRecordDeletionCommand.rst:27

    This sentence sounds strange.
  9. Christoph Lehmann uploaded patch set 4 V +1 12/03/22, 11:24

  10. Christoph Lehmann commented on patch set 4 12/03/22, 11:28

    Feature-99258-AddMinimumAgeOptionToRecordDeletionCommand.rst:25 Reply

    Done

    Feature-99258-AddMinimumAgeOptionToRecordDeletionCommand.rst:27 Reply

    I leave it away. Should be self-explanatory, that records marked for deletion and having no tstamp field get deleted. Please feel free to re-phrase all my wording
  11. core-ci voted on patch set 4 V +1 12/03/22, 11:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34589

  12. Stefan Bürk commented on patch set 4 12/04/22, 00:04

    DeletedRecordsCommand.php:104

    The part after "-" should be surrounded by rounded bracket to emphasise visually the operation precedence (and reduce cognitivae load). ``` ... ((int)$input->getOption('min-age')) * 86400; ... ((int)$input->getOption('min-age') * 86400);

    DeletedRecordsCommand.php:202

    This variable naming is kind of confusin, and even more in contrast to `$maximumTimestamp`. Would suggest to use here something like e.g. `$maximumTimestampBoundaryConstraint` or `$maximumTimetampConstraint`. Having `minimum` in the name combined with a `lower than (lt)` condition is not really obious and needs a really contentrated look on this.

    DeletedRecordsCommand.php:203

    We should add here a check, thet `$maximumTimestamp` is greater than zero.

    DeletedRecordsCommand.php:218

    Not a fan of conditionally adding a empty string here, also not a "problem" right now. The where condition should only added if table has a tsstamp field configured. Either by splitting the where and execute up and add it inbetween .. or build the where expressions and unpack them in where only.
  1. Chris Müller uploaded patch set 5 V +1 12/04/22, 18:04

  2. core-ci voted on patch set 5 V +1 12/04/22, 18:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34607

  3. Christoph Lehmann uploaded patch set 6 V +1 12/04/22, 19:04

  4. core-ci voted on patch set 6 V +1 12/04/22, 19:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34612

  5. Christoph Lehmann commented on patch set 6 12/04/22, 19:21

    Thanks for your review!

    DeletedRecordsCommand.php:104 Reply

    Done

    DeletedRecordsCommand.php:202 Reply

    Done

    DeletedRecordsCommand.php:203 Reply

    I don't see the benefit adding this check. To get $maximumTimestamp below zero one needs to use --min-age 738858 (days since start of Unix timestamp), which is very unlikely.

    DeletedRecordsCommand.php:218 Reply

    Done
  6. Chris Müller commented on patch set 6 12/04/22, 20:02

    Sadly, the last patchset overrode my docs changes :-(
  7. Stefan Bürk commented on patch set 6 CR -1 12/04/22, 20:13

    DeletedRecordsCommand.php:203 Reply

    I disagree here. You are creating a database query based on provided method arguments. It does not matter where it is called or not, as the argument is a int it can be technically zero or negative, both leading to suerpflous and in some constellation to errounous database query. That must be guarded. So please add the check to ensure that proper query building is ensured - not guessed or assumed.
  8. Benni Mack commented on patch set 7 CR -1 V +1 12/06/22, 10:48

    Published edit on patch set 6.
  9. core-ci voted on patch set 7 V +1 12/06/22, 11:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34707

  10. Christoph Lehmann uploaded patch set 8 V +1 12/12/22, 22:43

  11. core-ci voted on patch set 8 V +1 12/12/22, 23:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34961

  12. Christoph Lehmann commented on patch set 8 12/13/22, 08:29

    DeletedRecordsCommand.php:203 Reply

    Okay, thanks for the explanation, got you. I also removed the code-smell, see removed big comment block.
  13. Nikita Hovratov uploaded patch set 9 V +1 12/14/22, 18:49

  14. Nikita Hovratov commented on patch set 8 12/14/22, 18:50

    Feature-99258-AddMinimumAgeOptionToRecordDeletionCommand.rst:16

    gets deleted

    Feature-99258-AddMinimumAgeOptionToRecordDeletionCommand.rst:21

    were marked

    DeletedRecordsCommand.php:78

    `a record` or `records need`

    DeletedRecordsCommand.php:188

    If the page itself is deleted, it normally means all records on that page are deleted as well, or else they are orphaned. I would avoid the tstamp comparison on L:211 if this is the case.

    DeletedRecordsCommand.php:203 Reply

    nice!
  15. core-ci voted on patch set 9 V +1 12/14/22, 18:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35119

  16. Chris Müller uploaded patch set 10 V +1 12/14/22, 19:03

  17. core-ci voted on patch set 10 V +1 12/14/22, 19:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35120

  18. Christoph Lehmann uploaded patch set 11 V +1 12/17/22, 18:14

  19. Christoph Lehmann commented on patch set 11 12/17/22, 18:18

    DeletedRecordsCommand.php:188 Reply

    Normally it should not be needed. When i delete a page, then its records get deleted too and get the same `tstamp`, because it happens in the same request. But yes, lets don't check it when the page gets deleted.
  20. core-ci voted on patch set 11 V +1 12/17/22, 18:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35218

  21. Chris Müller uploaded patch set 12 V +1 02/08/23, 18:00

  22. core-ci voted on patch set 12 V +1 02/08/23, 18:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37405

  23. Anja Leichsenring voted on patch set 12 V +1 CR +1 02/16/23, 19:09

  24. Stefan Bürk voted on patch set 12 V +2 CR +2 02/16/23, 19:23

  25. Stefan Bürk merged patch set 13 02/16/23, 19:24