Review main Ready for review

97241[BUGFIX] Filter Extbase queries by current workspace

Garvin Hicking CR +1 V +1 Normal +131 −4 updated 11/11/26, 11:55

Commit message

Records created in a workspace have `t3ver_oid = 0`, so the filter on
`t3ver_oid` alone does not exclude them.

In backend context, and in frontend context with ignored enable fields,
nothing else checks `t3ver_wsid`. Extbase repositories therefore
returned unpublished records in the live workspace and in other
workspaces, while `count()` already applied the WorkspaceRestriction
and disagreed with `execute()`. Constraints on relations, such as
`posts.title`, matched records of other workspaces as well.

The query parser now adds the WorkspaceRestriction for the current
workspace to the query and to the subselects of the language overlay.
The query builder applies it to joined tables as well. Versions of the
current workspace are not filtered from the joins by it, so in the
backend a constraint on a relation keeps matching a value changed in
that workspace.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 3
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/41/97241/3 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/41/97241/3 && git cherry-pick FETCH_HEAD

Review

  • Code review CR +1 Needs a vote
    • Oliver Klee +1
    • Alexander Schnitzler +1
  • Verified V +1 Needs a vote
    • Oliver Klee +1
    • Alexander Schnitzler +1
    • core-ci +1 CI

Merge conflicts 7

Issues 1

Files 3

Review log 1417

  1. Garvin Hicking uploaded patch set 1 10/30/26, 15:04

  2. core-ci voted on patch set 1 V +1 10/30/26, 15:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112888

  3. Oliver Klee commented on patch set 1 V +1 10/30/26, 16:05

    WorkspaceTest.php:58

    This shouldn't be needed as we restore the globals for functionals anyway in the PHPUnit configuration file.
  4. Garvin Hicking commented on patch set 1 10/30/26, 16:08

    WorkspaceTest.php:58 Reply

    Yes, you're right, I'll need to remove this. I targeted the execution wrongly to one test method and it didn't perform it outside properly, thanks for pointing it out!
  5. Garvin Hicking commented on patch set 2 V +1 10/30/26, 20:15

    Published edit on patch set 1.
  6. Garvin Hicking commented on patch set 2 10/30/26, 20:16

    WorkspaceTest.php:58 Reply

    Done
  7. core-ci voted on patch set 2 V +1 10/30/26, 20:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112906

  8. Benni Mack voted on patch set 2 CR +1 V +1 10/30/26, 20:48

  9. Oli Bartsch commented on patch set 2 V -1 10/30/26, 21:36

    Unresolved

    Let me check please
  10. Oli Bartsch commented on patch set 2 10/30/26, 21:47

    Typo3DbQueryParser.php:318 Unresolved

    The two subselect builders have the same gap. Suggest to either add the restriction there as well or open a follow-up issue.

    Typo3DbQueryParser.php:651

    The `t3ver_wsid` filter only covers the root alias. With `OVERLAYS_MIXED` (the default `fallback` language type), the translated-only subselect doesn't check `t3ver_wsid`, so a translation created new in a workspace still hides its live default record. Meanwhile the draft translation itself is now filtered out, so neither record shows in live. Joined property paths like `posts.title` can still match draft rows too. Please add `WorkspaceRestriction` for the current workspace in `initializeQueryBuilder()`, since `leftJoin()` puts it into the ON clause and covers all joins. Add the same restriction to both language subselect builders, because they are built separately and never inherit it. Please keep `t3ver_oid = 0` at the root, as the restriction lets move pointers through.

    WorkspaceTest.php:304 Unresolved

    This only checks the draft title... Can we add `self::assertSame(count($titles), $query->count())` + a case with `LanguageAspect(1, 1, OVERLAYS_MIXED)` (live default record plus a translation new in workspace 1, expecting the default in live), and finally a `equals('posts.title', ...)` constraint on a post new in another workspace (expecting no match)?
  11. Benni Mack commented on patch set 2 CR 0 V 0 10/30/26, 22:00

    Typo3DbQueryParser.php:651 Reply Unresolved

    good catch!
  12. Oli Bartsch uploaded patch set 3 V +1 11/03/26, 09:48

  13. core-ci voted on patch set 3 V +1 11/03/26, 09:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113136

  14. Garvin Hicking commented on patch set 3 11/03/26, 10:26

    thanks Oli; lgtm
  15. Oliver Klee voted on patch set 3 V +1 11/03/26, 11:13

  16. Alexander Schnitzler voted on patch set 3 CR +1 V +1 11/11/26, 11:10

  17. Oliver Klee voted on patch set 3 CR +1 11/11/26, 11:55