Review main Abandoned Breaking

74652[!!!][TASK] Add types to Scheduler Tasks

crell CR 0 V 0 Hard +170 −363 updated 08/01/22, 18:04

Commit message

This patch adds types to the Scheduler's AbstractTask,
and its children.  That allows for a little code simplification
in a few places and the removal of a PHPStan warning.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 20

Review log 1316

  1. crell uploaded patch set 1 05/16/22, 18:46

  2. core-ci voted on patch set 1 V -1 05/16/22, 18:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27259

  3. Oliver Klee commented on patch set 1 05/16/22, 18:57

    ValidatorTask.php:46

    Please let’s add default values to the typed fields as they are not initialized in the constructor, which could lead to errors when they are accessed.

    CleanerTask.php:156

    We can annotate this with string[] to be consistent to the annotation of the property. Ditto for the getter.
  4. crell commented on patch set 1 05/16/22, 19:31

    ValidatorTask.php:46 Reply Unresolved

    There's no direct way to mimic the old behavior. They would have evaluated to null, but then are concatenated into a string for a CLI command, so would have cast to empty string. Setting them to 0 may or may not be the same thing. (It probably is not.) I can set them to 0, but that doesn't actually do anything useful. If anything, it hides what should be an error case by passing 0 to the command line, which may or may not do something useful. Leaving them unset would at least generate an error if they're used while unset. Unless someone can confirm that 0 is reasonable default settings for the CLI command that gets run? If so, then it's fine. (They're only used in setCliArguments(), I think.)

    CleanerTask.php:156 Reply

    Done
  5. crell uploaded patch set 2 05/16/22, 19:31

  6. core-ci voted on patch set 2 V +1 05/16/22, 19:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27261

  7. Oliver Klee commented on patch set 2 05/17/22, 11:38

    AbstractTask.php:44

    This comment is redundant with the type declaration, and we can remove it.

    AbstractTask.php:46

    As this property is set in the constructor, it does not need to be nullable.

    AbstractTask.php:288

    int $timestamp

    AbstractTask.php:310

    : void

    AbstractTask.php:558

    We can make this PHPStan-readable: int<self::TYPE_SINGLE, self::TYPE_RECURRING> See: https://phpstan.org/writing-php-code/phpdoc-types#integer-ranges

    AbstractTask.php:569

    We can drop this annotation.

    FileStorageExtractionTask.php:32

    We can drop this comment as it's redundant.

    FileStorageExtractionTask.php:37

    Ditto.

    FileStorageExtractionTask.php:70

    Ditto.

    FileStorageIndexingTask.php:32

    We can remove this comment as it's redundant.

    FileStorageIndexingTask.php:58

    We can remove this comment as it's redundant.

    IpAnonymizationTask.php:38

    We can remove this comment as it's redundant.

    OptimizeDatabaseTableTask.php:72

    We can remove this annotation as it's redundant.
  8. crell commented on patch set 2 05/17/22, 14:19

    AbstractTask.php:44 Reply

    Done

    AbstractTask.php:46 Reply

    Done

    AbstractTask.php:288 Reply

    Done

    AbstractTask.php:310 Reply

    Done

    AbstractTask.php:558 Reply

    Oo, nifty. (Ideally we'd convert this to an enum, but that's for another patch.)

    AbstractTask.php:569 Reply

    Done

    FileStorageExtractionTask.php:32 Reply

    Done

    FileStorageExtractionTask.php:37 Reply

    Done

    FileStorageExtractionTask.php:70 Reply

    Done

    FileStorageIndexingTask.php:32 Reply

    Done

    FileStorageIndexingTask.php:58 Reply

    Done

    IpAnonymizationTask.php:38 Reply

    Done

    OptimizeDatabaseTableTask.php:72 Reply

    Done
  9. crell commented on patch set 2 05/17/22, 14:57

    AbstractTask.php:46 Reply

    Actually, nope. The unsetScheduler() method explicitly sets it to null. (I have no idea why that's there, it's probably the wrong way to do whatever it's doing, but that's a separate issue.)
  10. crell uploaded patch set 3 05/17/22, 14:58

  11. core-ci voted on patch set 3 V +1 05/17/22, 15:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27282

  12. Oliver Klee commented on patch set 3 05/17/22, 15:43

    AbstractTask.php:46 Reply

    Ack
  13. Oliver Klee voted on patch set 3 CR +1 05/17/22, 15:45

  14. Oliver Klee wrote 05/18/22, 19:41

    Removed reviewer Oliver Klee with the following votes: * Code-Review+1 by Oliver Klee
  15. Stefan Bürk commented on patch set 3 05/18/22, 22:48

    AbstractTask.php:46 Reply

    Tasks are serialized/unserialzied in the database (not a good way). @lolli already mentioned this recently in the core dev channel. This should be changed. Thus property must be nullable so it can be unset. Beside this, it's commented in the method: ``` /** * Unsets the internal reference to the singleton instance of the Scheduler * and the logger instance. * This is done before a task is serialized, so that the scheduler instance * and the logger instance are not saved to the database */ ```
  16. crell abandoned the change 08/01/22, 18:04

    Apparently scheduler is slated for removal anyway.