Review 13.4 Merged

90466[TASK] Refactor workspace BE module internals

Christian Kuhn CR +2 V +2 Expert +788 −1006 updated 08/22/25, 10:45

Commit message

The workspace BE module handling around the sys_workspace
and sys_workspace_stage DB records is a rather complex
mess involving the "model" clases WorkspaceRecord and
WorkspaceStage, the service classes WorkspaceService and
StagesService, plus the consuming controllers. The classes
are heavily entangled and know each other, some services are
stateful. There are duplicated and odd constructs like
creating a stage model object from a DB row, to later turn
it into an array representation again.

To tame all this, the patch establishes two new data objects
that represent workspace and stages. These substitute the
former "models", are readonly and tailored for the BE module
to contain what is needed during further processing. They are
created by two repository classes.

Services and consumers are adapted to work with these data
objects. Various minor adaptions reduce the number of DB
calls to calculate notification recipients, and to fix minor
issues in this area along the way.

All in all, the change turns the involved code into a much
more straight ahead solution, leading to more stateless
services, more obvious code, less unneeded abstraction and
less duplication. The entire thing should be significantly
more easy to grasp now.

Review

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

Issues 1

Files 21

Show 1 more file

Review log 1523

  1. Christian Kuhn uploaded patch set 1 08/21/25, 14:16

  2. Christian Kuhn commented on patch set 1 CR -1 08/21/25, 14:17

    testing details
  3. core-ci voted on patch set 1 V +1 08/21/25, 14:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83703

  4. Christian Kuhn uploaded patch set 2 CR -1 V +1 08/21/25, 15:50

  5. core-ci voted on patch set 2 V +1 08/21/25, 15:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83706

  6. Christian Kuhn uploaded patch set 3 V +1 08/21/25, 18:34

  7. core-ci voted on patch set 3 V +1 08/21/25, 18:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83708

  8. Christian Kuhn uploaded patch set 4 V +1 08/21/25, 19:48

  9. core-ci voted on patch set 4 V +1 08/21/25, 19:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83710

  10. Christian Kuhn uploaded patch set 5 08/21/25, 20:04

    Copied Votes: * Verified+1 (copy condition: "**changekind:NO_CHANGE**")
  11. Christian Kuhn uploaded patch set 6 V +1 08/21/25, 20:07

  12. Christian Kuhn commented on patch set 6 08/21/25, 20:10

    found two minor issues while testing the backport that i fixed here. i'll upmerge these to main as follow-up.
  13. core-ci voted on patch set 5 V +1 08/21/25, 20:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83711

  14. core-ci voted on patch set 6 V +1 08/21/25, 20:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83712

  15. Stefan Froemken updated the commit message in patch set 7 V +1 08/22/25, 06:37

  16. core-ci voted on patch set 7 V +1 08/22/25, 06:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83738

  17. Stefan Froemken commented on patch set 7 08/22/25, 07:14

    Nice clean-up. Can you streamline the variables a little bit? In one class you name it $currentWorkspace in another class $activeWorkspace and if you retrieve the workspace from BE_USER you also write "workspace", but its NOT a Workspace object, it's a workspace ID. I think the variablenames should respect that.

    DatabaseUserPermissionCheck.php:53

    Can we remove these self-explaining annotations? There are no additional information and the arguments and return values are types in method already.

    GeneralUtilityTest.php:849

    Why is this important? In general it is a "normal" PHP:explode which never removes duplicate values

    WorkspaceSelectorToolbarItem.php:34

    Aua...hard to remove because of RequestAwareToolbarItemInterface, right?

    AjaxDispatcher.php:40

    protected const?

    RemoteServer.php:114

    No try-catch?

    RemoteServer.php:303

    Just pseudo stage. I have no clue what you mean with "execute"

    Workspace.php:25

    Just for my brain. If I add one or two additional columns to sys_workspace I'm completely lost. It's not possible to retrieve my own fields anywhere again in various eventlisteners of workspace code, right. If I get the WS UID I have to retrieve the sys_workspace record again with plain ConnectionPool.

    WorkspaceRepository.php:39

    Isn't that a job for BitSet?
  18. Christian Kuhn commented on patch set 7 08/22/25, 10:33

    Reply

    since this is the backport of the main patch, i'll keep this for now. the patch creates the foundation for further refactorings that should be much easier now, an unfortunate variable name is not critically important at this point. i hope this point of view is ok with you at the moment.

    DatabaseUserPermissionCheck.php:53 Reply

    Done

    GeneralUtilityTest.php:849 Reply

    it wasn't obvious to me. this added test case just specifies the detail behavior a bit better and does not hurt.

    WorkspaceSelectorToolbarItem.php:34 Reply

    yeah. part of the current toolbar behavior. i guess that won't change anytime soon.

    AjaxDispatcher.php:40 Reply

    will be kept in v13, has been dissolved in main already.

    RemoteServer.php:114 Reply

    is validated by be-auth code already. should be fine.

    RemoteServer.php:303 Reply

    see description in the stages repository class.

    Workspace.php:25 Reply

    yeah. this DO is a contract between db state and the application. there aren't many events anyways, this DO does not represent 'everything' from DB, and it is tailored for the BE module that isn't trivial to adapt at the moment. this final is fine, at least for the time being. we need a solid ground to allow further refactoring.

    WorkspaceRepository.php:39 Reply

    too much overhead with too little gain in this case i'd say. still unsure on how the permission system will evolve, so let's keep it very simple for now.
  19. Christian Kuhn uploaded patch set 8 V +1 08/22/25, 10:33

  20. Stefan Froemken voted on patch set 8 CR +1 08/22/25, 10:41

  21. core-ci voted on patch set 8 V +1 08/22/25, 10:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83751

  22. Christian Kuhn voted on patch set 8 CR +2 V +2 08/22/25, 10:45

  23. Christian Kuhn merged patch set 9 08/22/25, 10:45