Review main Ready for review Quiet

97294[BUGFIX] Set language of new records without language field access

Benni Mack CR 0 V 0 Normal +160 −5 updated 11/04/26, 07:16

Commit message

When an editor without access to the exclude field
"sys_language_uid" translates a record with "localize" or
"copyToLanguage", or creates a record in another language, the
record is stored in the default language, as DataHandler drops
the language field.

The language of a new record is now governed by the language
permissions only, which DataHandler checks for new records
anyway. Changing the language of an existing record still
requires access to the field.

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 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/94/97294/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/94/97294/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 20

Issues 1

Files 5

Review log 810

  1. Benni Mack uploaded patch set 1 11/02/26, 06:34

  2. core-ci voted on patch set 1 V +1 11/02/26, 06:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113069

  3. Benni Mack uploaded patch set 2 V +1 11/02/26, 08:51

  4. core-ci voted on patch set 2 V +1 11/02/26, 09:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113074

  5. Daniel Windloff commented on patch set 2 11/03/26, 06:10

    I prefer Georg's approach for main, as it does not add a new special condition for language fields: https://review.typo3.org/c/Packages/TYPO3.CMS/+/95929
  6. Oli Bartsch commented on patch set 2 11/03/26, 08:49

    Reply

    I think we still need this one. 1. 95929 is main only. 97080 also exists in 14.3, and dropping the exclude flag there would change the UI on a release branch. 14.3 needs a DataHandler fix whatever we decide for main. 2. 95929 does more than fix the bug. It lets editors change the language of existing records. With the exclude flag gone and LanguageFieldType::supportsAccessControl() returning false, every editor with access to two languages can switch an existing record from default to DA, and its translations end up with an l18n_parent that points to a DA record. DataHandler only checks checkLanguageAccess() for the new value, and FormEngine does not lock the field. Admins also lose the only way to prevent this, since allowed_languages cannot express "may work in EN and DA, but may not move records between them". 3. The condition here is not a language special case for its own sake. It separates two different things: choosing the language of a new record (localize, copyToLanguage, new content in a language column), which allowed_languages already governs, and changing the language of an existing record, which stays behind the exclude right. 4. The two patches don't rule each other out. If 95929 goes into main, it needs a guard against language changes on existing records, and that is a DataHandler condition as well. Personally I think editors should never change the language of an existing record through the form at all, since that's what the translation wizard is for. That would be the follow-up for main, on top of this patch. I abandoned my own in favour of this one. It does the same with far less state.
  7. Daniel Windloff commented on patch set 2 11/03/26, 09:31

    Reply

    Hey Oli, thanks for your reply. Regarding the individual points: 1. My focus was exclusively on the resulting behavior in the `main` branch. 2. and 4. So, is the intended goal for `main` that all language fields can be processed within the `DataHandler`, while their representation in the `FormEngine` is set to `readOnly`? 3. My impression regarding `exclude` was that the distinction isn't entirely clear. For instance, in the case of a `slug` with exclude and without permissions, I would expect the value to be calculated based on the generator fields, but not allowed to be overwritten. Is there a defined distinction for exclude that I might have overlooked?
  8. Benni Mack commented on patch set 2 11/03/26, 09:52

    Reply

    I do think we need this change (or a similar) -> we do not want to have corrupt state in the database which we then need to clean up. This is language, "slug" does not have to be a slug for the website, it's not like a "system-related" field, you know what I mean? FOr pages.slug we could argue though ;)
  9. Daniel Windloff commented on patch set 2 11/04/26, 06:41

    Reply

    Sorry if I’m holding things up at the moment; I’m probably just a bit out of the loop right now. I’m trying to sort out the different approaches for myself. The aim is clear: we need a database state that isn’t corrupted. I’m not sure I’ve got a proper knowledge of the situation, which is why I’ve commented on the three different patches. It seemed to me that they were addressing similar issues. The issue is: what is allowed in the language field. There’s are allowed_languages and exclude as permissions and the dependency on the site, and the relationship between l10n_parent (and l10n_source). Editing a record: - If l10n_parent > 0, do not allow editing of the language field, as this would otherwise corrupt the translation in connected mode - Conversely, the l10n_parent field must not be edited either; if anything, both fields must be validated together. - If l10n_parent = 0 and exclude is permitted and the language is authorised for the backend user, the value of the field may be changed; otherwise, it may not - If there are records in the target language of the language change, that are in connected mode, this language must not be reselected either, as otherwise a matching l10n_parent would have to be selected. - If the language is not present on the site, it should not be selectable. Creating a new record (including translate in free and connected mode): - Check whether the language is present in allowed_languages and on the site; if not, do not create the record - Check whether a record in the target language already exists in connected mode; if so, only allow that one - Exclude does not need to be taken into account General conclusion: - Selecting -1 for sys_language_uid is currently the only valid use case for editing the language field; all other use cases are covered by wizards. Once the -1 normalisation error has been removed, there will no longer be any reason to edit the field. - All language-related fields should then be non-editable in the backend in the future. - Exclude should then generally no longer play a role. The approach of not evaluating it at all, as in Georg’s patch, is therefore correct. The current behaviour regarding editing possibilities in the backend is incorrect, as the fields should not be changeable. - The site must not delete a created language if it is used in a record or all translations of the language in the site must be removed. Conclusion regarding this patch: - Should exclude also be ignored for the other language-related fields when creating new records? - Should HIDE_FOR_NON_ADMINS should be ignored as well for language related columns? Is this heading in the right direction? What do you think?
  10. Benni Mack commented on patch set 2 11/04/26, 07:16

    Reply Unresolved

    hmm, maybe the initial problem of this patch isn't clear. A non-admin with allowed_languages=0,5 for example wants to translate a tt_content (or any other) where this person does NOT have access to its sys_language_uid field is translating a record with UID 13 from 0 to 5. The reason for the fix: It does the translation but then does not set sys_language_uid=5 in the DB but "0", BUT it also set the l10n_parent=13. This way, the editor has no clue what went wrong AND we have a weird DB state (language=0 AND l10n_parent>0) in the DB. That's all I want to fix.