Review main Abandoned

74346[BUGFIX] Fix invalid array accesses in the workspaces DataHandlerHook

Oliver Klee CR 0 V 0 Easy +4 −8 updated 09/26/22, 10:06

Commit message

On an associative DB query result row, the page UID needs to be
retrieved via $row['pid'], not via $row[0].

Used command:

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 2

Review log 1722

  1. Oliver Klee uploaded patch set 1 04/18/22, 14:09

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

  3. Stefan Bürk commented on patch set 1 CR -1 04/18/22, 15:57

    DataHandlerHook.php:1408

    'uid' does not exist in result row(s). See QueryBuilder above. I guess it should be $row['pid'], what do you think ? Doing this before L1404 and use it for the array addition also would make the usage clearer.
  4. Oliver Klee commented on patch set 1 04/18/22, 16:20

    DataHandlerHook.php:1408 Reply

    Ack
  5. Oliver Klee uploaded patch set 2 04/18/22, 17:21

  6. Oliver Klee commented on patch set 2 04/18/22, 17:22

    DataHandlerHook.php:1408 Reply

    Done.
  7. Oliver Klee uploaded patch set 3 04/18/22, 17:23

  8. Stefan Bürk commented on patch set 3 04/18/22, 17:25

    DataHandlerHook.php:1408 Reply

    Commit message wrong now ;) Still searching how to test/debug this ... do you have a tip ? Could not get it to stop at the breakpoint yet ...
  9. core-ci voted on patch set 2 V +1 04/18/22, 17:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26160

  10. core-ci voted on patch set 3 V +1 04/18/22, 17:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26161

  11. Oliver Klee updated the commit message in patch set 4 04/18/22, 17:38

  12. Oliver Klee commented on patch set 4 04/18/22, 17:40

    DataHandlerHook.php:1408 Reply

    Ah, damn. Thanks. Fixed and repushed. I honestly have no idea how to manually test this. I just went by the PHPStan warning, and by reading, the existing code definitely was not be correct.
  13. core-ci voted on patch set 4 V +1 04/18/22, 17:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26163

  14. Simon Schaufelberger uploaded patch set 5 09/22/22, 00:13

  15. core-ci voted on patch set 5 V +1 09/22/22, 00:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31402

  16. Christian Kuhn commented on patch set 5 09/22/22, 08:00

    that's a bug fix that changes behavior since the methods now "works". what's the impact?
  17. Oliver Klee commented on patch set 5 09/22/22, 08:23

    Honestly, I don‘t know. I know that without the change, the could could in no way work.
  18. Christian Kuhn commented on patch set 5 09/22/22, 08:33

    alright. i think we should get an idea on how this is triggered before merging.
  19. Christian Kuhn commented on patch set 5 CR -1 09/22/22, 09:05

    some insight: -> core DataHandler process_cmdmap() (called when records are pushed live, stage is changed, deleted, etc) -> workspaces DataHandlerHook processCmdmap_beforeStart() -> workspaces CommandMap->process() -> workspaces CommandMap->resolveWorkspacesSetStageDependencies() -> workspaces CommandMap->applyWorkspacesSetStageBehaviour() via invokeWorkspacesSetStageItems() -> workspaces DataHandlerHook findPageIdsForVersionStateChange() ... The DataHandler allows modifying the main command map construct, hooks add additional stuff to it. for instance, when a parent record goes live, it looks for inline children and takes care they are added to the command map as well ... something like that. Class CommandMap in general hasn't been touched much in recent years and is pretty hard to understand due to lots of indirect $this->$myCallback() logic. I think we should simplify this class by rewriting it to avoid the entire callback magic. We could merge method findPageIdsForVersionStateChange() from DataHandlerHook into CommandMap along the way, or maybe dissolve the CommandMap class entirely by merging it into ws DataHandlerHook. Comments on what exactly is going on in the methods and how the command map is manipulated and why need to be added along the way. At first glance it looks as if there is quite a bit of dead code anyways - especially the "swap" related stuff smells fishy. --> I think we should clean this mess up to get an overview, and after that have a look at this specific detail. What do you think?
  20. Oliver Klee commented on patch set 5 09/22/22, 09:47

    Reply

    Thanks, yes, that approach makes a lot of sense.
  21. Christian Kuhn commented on patch set 5 09/26/22, 10:04

    will be fixed with https://review.typo3.org/c/Packages/TYPO3.CMS/+/75861 by deleting the code ^^
  22. Christian Kuhn abandoned the change 09/26/22, 10:06