Review main Merged

88103[BUGFIX] Prevent calls on null in scheduler module

Lina Wolf CR +2 V +2 Easy +15 −9 updated 02/09/25, 19:34

Commit message

If you are opening the scheduler menu after an update there
can be outdated, broken tasks that do not resolve.

Prevent null type errors by testing for the type before calling
the type-save methods.

Review

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

Issues 1

Files 1

Review log 1317

  1. Lina Wolf uploaded patch set 1 02/08/25, 13:14

  2. core-ci voted on patch set 1 V -1 02/08/25, 13:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73805

  3. Lina Wolf uploaded patch set 2 V -1 02/08/25, 14:41

  4. core-ci voted on patch set 2 V +1 02/08/25, 14:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73806

  5. Stefan Bürk commented on patch set 2 02/08/25, 21:32

    SchedulerModuleController.php:410

    Throwing a exception to directly catch it in a surrounding try-catch block - and even directly is kind of Exception communication missuse in my eyes. The exception message is not used in the catch block, so wie can simply do the same lines here. I know that this dupplicates the addMessage and direct return calls, but at least it removes the confusion about the sense throwing this exception in this case. Another soulution could be to move this check after the try-catch block, doing the addMessage and return only there. Keeping the catch block as noop. I would rather suggest to do the whole block like ```php $taskRecord = null; try { $taskRecord = $this->taskRepository->findRecordByUid($taskUid); } catch (\OutOfBoundsException) { // No action to take - handled below. } if ($taskRecord === null) { // Task not found - removed meanwhile? $this->addMessage($view, sprintf($languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.taskNotFound'), $taskUid), ContextualFeedbackSeverity::ERROR); return $this->renderListTasksView($view, $moduleData); } ``` Thinking about it, I don't get why this global namespace exception is catched here leaving all other exception unhandled. The called method in the TaskRepository does not throw that global namespace excpetion directly, nor does this the TYPO3 QueryBuilder, ExpressionBuilder or Doctrine DBAL QueryBuilder/ExpressionBuilder. That means, we need to think about removing the try-catch here at all .. thus commenting this for now instead of pushing to the change. Going to revisit and rethink this after some sleep.

    SchedulerModuleController.php:412

    Unrelated, but `$e` is not used in the catch block and can be removed.

    SchedulerModuleController.php:427

    This exception here does not serve any purpose at all and is directly catched. As already mentioned for the change above, this is a missue of exception communication here. I would rather change the whole code-block here (L423-429) to ```php $task = null; $class = null; $isInvalidTask = false; try { if (isset($taskRecord['serialized_task_object']) && is_string($taskRecord['serialized_task_object']) && $taskRecord['serialized_task_object'] !== '' ) { $task = $this->taskSerializer->deserialize($taskRecord['serialized_task_object']); $class = $this->taskSerializer->resolveClassName($task); } } catch (InvalidTaskException) { $isInvalidTask = true; $class = $this->taskSerializer->extractClassName($taskRecord['serialized_task_object']); } ``` What do you think ?
  6. Lina Wolf uploaded patch set 3 V +1 02/09/25, 06:48

  7. Lina Wolf commented on patch set 3 02/09/25, 06:51

    SchedulerModuleController.php:410 Reply

    This sounds like a good idea. I applied your changes and left a todo about why we catch this one exception here. As the catch block has been there before my change I wouldnt feel save to remove it.

    SchedulerModuleController.php:412 Reply

    Done

    SchedulerModuleController.php:427 Reply

    Looks much cleaner to me however I would move the if block outside the try block as calling extractClassName also expects a string.
  8. Lina Wolf commented on patch set 3 02/09/25, 06:53

    SchedulerModuleController.php:138

    CGL insists on changing these lines although i never touchted them. No idea why.
  9. core-ci voted on patch set 3 V +1 02/09/25, 06:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73829

  10. Christian Kuhn uploaded patch set 4 V +1 02/09/25, 18:25

  11. Christian Kuhn commented on patch set 3 02/09/25, 18:26

    SchedulerModuleController.php:138 Reply

    probably because of trailing ',' ... streamlined now.
  12. Christian Kuhn commented on patch set 4 02/09/25, 18:26

    SchedulerModuleController.php:410 Reply

    Done

    SchedulerModuleController.php:427 Reply

    Done
  13. Christian Kuhn commented on patch set 4 02/09/25, 18:27

    SchedulerModuleController.php:410 Reply

    Done

    SchedulerModuleController.php:427 Reply

    Done
  14. core-ci voted on patch set 4 V +1 02/09/25, 18:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73854

  15. Stefan Bürk voted on patch set 4 CR +1 V +1 02/09/25, 19:02

  16. Christian Kuhn voted on patch set 4 CR +2 V +2 02/09/25, 19:23

  17. Christian Kuhn merged patch set 5 02/09/25, 19:34