Review main Merged

93177[BUGFIX] Allow editors to localize root level records

Georg Ringer CR +2 V +2 Normal +128 −9 updated 08/26/26, 07:55

Commit message

Records on the root level (pid = 0) like sys_file_metadata could not be
localized by non-admin users: the wizard endpoints checked access with
BackendUtility::readPageAccess(), which can only succeed on pid = 0 for
admins.

For localizable tables which lift the root level restriction for
non-admins (security.ignoreRootLevelRestriction), the "tables_modify"
permission of the table itself is authoritative instead. This is
stricter than the check used for pid > 0, which only requires PAGE_SHOW
on the page and never looks at the table.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Andreas Kienast +1
    • Benjamin Kott +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Riccardo De Contardi +1
    • Benjamin Kott +1
    • core-ci +1 CI

Issues 2

Files 4

Review log 2535

Show 610 earlier messages
  1. Georg Ringer uploaded patch set 1 03/13/26, 12:53

  2. Georg Ringer commented on patch set 1 03/13/26, 12:53

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 03/13/26, 13:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97895

  4. Georg Ringer rebased onto patch set 2 V +1 04/21/26, 14:40

  5. core-ci voted on patch set 2 V +1 04/21/26, 15:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100653

  6. Benni Mack updated the commit message in patch set 3 V +1 04/22/26, 07:20

  7. Benni Mack rebased onto patch set 4 05/04/26, 18:16

  8. core-ci voted on patch set 4 V +1 05/04/26, 18:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/101488

  9. Benni Mack rebased onto patch set 5 V +1 07/24/26, 14:29

  10. core-ci voted on patch set 5 V +1 07/24/26, 14:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105329

  1. Benni Mack rebased onto patch set 6 V +1 08/05/26, 08:06

  2. core-ci voted on patch set 6 V +1 08/05/26, 08:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105968

  3. Juliane Wundermann voted on patch set 6 CR +1 V +1 08/06/26, 19:12

  4. Benni Mack rebased onto patch set 7 CR +1 V +1 08/12/26, 11:18

  5. core-ci voted on patch set 7 V +1 08/12/26, 11:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106510

  6. Markus Klein commented on patch set 7 08/14/26, 22:20

    LocalizationController.php:164

    redundant comment

    LocalizationController.php:245

    redundant comment

    LocalizationController.php:290

    redundant comment

    LocalizationController.php:772

    please add a comment why we need this exception for pid=0
  7. Stefan Bürk commented on patch set 7 CR -1 08/15/26, 18:07

    Thanks for tackling this, the bug is real and #110365 documents it nicely. I confirmed the mechanism: BackendUtility::readPageAccess() returns truthy for pid=0 only for admins, and sys_file_metadata has rootLevel => 1, so the three wizard AJAX endpoints answer 403 for editors. Two things I would like to see changed before this goes in, plus Markus' open points. 1. The capability. canExistOnRootLevel() answers "may records of this table be stored on pid 0", but the question this gate has to answer is "may a non-admin work with root-level records of this table". Core has a dedicated flag for that - security.ignoreRootLevelRestriction - and every other place that makes this decision uses it: DatabaseUserPermissionCheck (lines 100/133), RecordListController:275, ElementInformationController:111/785, ElementHistoryController:541, RecordHistory:527, SuggestWizardController:217, Clipboard:711, WorkspaceService:322/444/856 and, most importantly, DataHandler:7509 and :7680 - the checks that will later adjudicate the localize command this wizard prepares. For sys_file_metadata, sys_category and sys_file_reference the two predicates coincide (all three set the flag), so switching to shallIgnoreRootLevelRestriction() keeps #109233 fixed. They diverge for tables that set rootLevel but deliberately omit the flag - tx_styleguide_ctrl_common in our own tree, and any third-party table with rootLevel => 1 plus a languageField. For those, the wizard would currently walk an editor through all four steps and then let DataHandler refuse the command, after having disclosed which translations of that record exist. Please use shallIgnoreRootLevelRestriction(). 2. Tests. This is a permission change and LocalizationControllerTest already covers all three patched endpoints - but only with setUpBackendUser(1), which is exactly why this could regress. Please add: admin unchanged; editor with tables_modify on sys_file_metadata gets the language list; editor without it gets 403; editor with tables_modify on a root-level table without ignoreRootLevelRestriction gets 403 (this one distinguishes the two capabilities); and a language-access case, so the checkLanguageAccess() chain through getSystemLanguages(0) stays covered. Smaller points: * hasCapability(TcaSchemaCapability::RestrictionRootLevel) is hardcoded to true in TcaSchema::hasCapability() ("This is an implicit restriction with a custom configuration"), so that && term is dead. It reads like a guard but is not one - please drop it. * +1 to Markus on all four comments. The pid === 0 bypass in particular needs a "why" comment, and the method deserves a PHPDoc: it is the only permission gate of three AJAX endpoints. Worth noting in it that tables_modify is stricter than the pid > 0 path, which only requires PAGE_SHOW. * The method returns array|false but all three callers only test truthiness, and the synthetic ['uid' => 0] has a different shape from readPageAccess()'s ['_thePath' => '/']. Returning bool would make the intent clearer. * Commit message: subject is 75 chars (target 52) - e.g. "[BUGFIX] Allow editors to localize root level records"; the first body line is 82 chars and must wrap at 72; sys_filemetadata should be sys_file_metadata; consider Related: #110365. Please also spell out in the body what replaces the page check and why it is equivalent - reviewers should not have to reconstruct the security argument from the diff. For the record on the security side, because that is the part that matters most here: the write path is unaffected. localize() has no controller-side check at all and delegates to DataHandler, so this only unblocks the UI leading there; language access stays enforced via getSystemLanguages(0) -> Site::getAvailableLanguages() -> checkLanguageAccess(); and check() still returns true for admins, so there is no admin regression from the new early return false. I do not see this as widening access unsafely. Unrelated to this patch, but noticed while reading the controller: getRecord(), getHandlers() and getContent() have no permission check at all - getContent() returns tt_content titles for an arbitrary pageUid and LocalizationRepository::getRecordsToCopyDatabaseResult() applies only Deleted/Workspace restrictions. That looks like a separate and bigger issue; could you file it?

    LocalizationController.php:772 Reply

    +1, and I would go a step further: the method deserves a PHPDoc as well, since it is the only permission gate in front of three AJAX endpoints. Two things worth capturing in that comment, because they are not obvious from the code: pid = 0 has no rows in pages, so BackendUtility::readPageAccess() can only ever succeed there for admins - that is what makes the special case necessary rather than merely convenient. And the replacement is not simply weaker: for pid = 0 it requires tables_modify on the table, which is stricter than the pid > 0 branch, where readPageAccess() only asks for PAGE_SHOW on the page and never looks at the table at all. Separately on the same line: I think the predicate itself should change from canExistOnRootLevel() to shallIgnoreRootLevelRestriction() - details in my patchset-level comment.
  8. Georg Ringer uploaded patch set 8 CR -1 V +1 08/24/26, 11:15

  9. core-ci voted on patch set 8 V +1 08/24/26, 11:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107027

  10. Markus Klein commented on patch set 8 08/24/26, 12:06

    LocalizationController.php:164 Reply

    Done

    LocalizationController.php:245 Reply

    Done

    LocalizationController.php:290 Reply

    Done

    LocalizationController.php:772 Reply

    Done
  11. Markus Klein voted on patch set 8 CR +1 08/24/26, 12:06

  12. Oli Bartsch commented on patch set 8 08/24/26, 13:28

    Nice patch! Two things: No tests are added. This is a permission-check change on backend AJAX endpoints, and LocalizationControllerTest still only exercises setUpBackendUser(1) (admin) everywhere. IMO a bugfix like this should ship with a test that reproduces the original 403 and proves the fix. Commit message indentation doesn't look correct. Also sys_filemetadata should be sys_file_metadata. And just a nit: getPageRecordForPermissionCheck() returns array|false, but all three callers only check truthiness and the synthetic ['uid' => 0] has a different shape than readPageAccess() result. A bool return would express the intent more directly.

    LocalizationController.php:783

    $schema->hasCapability(TcaSchemaCapability::RestrictionRootLevel) is hardcoded to true in TcaSchema::hasCapability(); this half of the && is dead code and reads like a guard that isn't one. Please drop it, leaving just the Language capability check.
  13. Georg Ringer uploaded patch set 9 CR +1 V +1 08/24/26, 16:23

  14. core-ci voted on patch set 9 V -1 08/24/26, 16:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107041

  15. Georg Ringer uploaded patch set 10 V -1 08/24/26, 18:55

  16. core-ci voted on patch set 10 V +1 08/24/26, 19:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107053

  17. Benjamin Kott uploaded patch set 11 V +1 08/24/26, 21:40

  18. Benjamin Kott commented on patch set 11 08/24/26, 21:41

    Bound the request in the test to a local variable: "new ServerRequest()->..." is PHP 8.4 syntax and would not have parsed on 14.3 (php ^8.2). Parentheses are no option, new_expression_parentheses strips them again. Dropped "This is the only permission gate in front of the wizard AJAX endpoints" from the PHPDoc — three of seven wizard routes call it — and added an assertion on the returned language list.
  19. core-ci voted on patch set 11 V +1 08/24/26, 21:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107058

  20. Benjamin Kott commented on patch set 11 CR +1 V +1 08/24/26, 21:48

    Reply

    All addressed: shallIgnoreRootLevelRestriction(), dead && term gone, bool return, all five test cases in. The unchecked endpoints get their own issue — 13.4 needs a different diff.

    Reply

    All four done: tests, commit message, sys_file_metadata, bool return.

    LocalizationController.php:783 Reply

    Dropped, only the Language check is left.
  21. Benjamin Kott commented on patch set 11 08/24/26, 22:46

    @stefan@buerk.tech here a followup 95408: [TASK] Harden localization wizard endpoints | https://review.typo3.org/c/Packages/TYPO3.CMS/+/95408
  22. Riccardo De Contardi commented on patch set 11 V +1 08/25/26, 09:05

    tested on latest main with the steps written on https://forge.typo3.org/issues/110365
  23. Andreas Kienast voted on patch set 11 CR +1 08/26/26, 07:11

  24. Georg Ringer voted on patch set 11 CR +2 V +2 08/26/26, 07:55

  25. Georg Ringer merged patch set 12 08/26/26, 07:55