Issue Bug Closed

#86493LocalizationStateSelector does not check if $localizationState is a TYPO3\CMS\Core\DataHandling\Localization\State object

Georg Tiefenbrunn 10/01/18, 10:06 updated 11/13/26, 11:52

Description

TYPO3 CMS 9.x composer latest master

I use tt_content.image in a custom CE and set 'allowLanguageSynchronization' => true by columnsOverrides:

'columnsOverrides' => [
    'image' => [
        'config' => [
            'behaviour' => [
                'allowLanguageSynchronization' => true,
            ],
...

This leads to:

> Error: Call to a member function isCustomState() on null
> in …typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php line 96

https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php#L72 should initialize $localizationState but this fails for field tt_content.image as State::getFieldNames() does not handle columnsOverrides but simply checks if $GLOBALS['TCA']['tt_content']['columns']['image']['config']['behaviour']['allowLanguageSynchronization'] is set.

Must have: LocalizationStateSelector should properly handle the errors if $localizationState is no State object

Could Have: LocalizationStateSelector could also handle fields using columnsOverrides.

Workaround: Set $GLOBALS['TCA']['tt_content']['columns']['image']['config']['behaviour']['allowLanguageSynchronization'] instead of using columnsOverrides.

Reviews 1

History 6

  1. Jonas Eberle commented <span data-processor="relativetime" data-value="2020-06-01T17:12:52+00:00" > 06/01/20, 17:12 </span>

    I can confirm for field tt_content.records (v9, too – didn’t test in v10)

  2. Daniel Phillips commented and changed TYPO3 Version 10 9 PHP Version 7.4 7.2 <span data-processor="relativetime" data-value="2021-05-14T14:08:06+00:00" > 05/14/21, 14:08 </span>

    Also ran into this bug on v10.4.16. Workaround worked.

  3. Georg Ringer commented <span data-processor="relativetime" data-value="2026-09-07T20:29:07+00:00" > 09/07/26, 20:29 </span>

    Checked against current main (15.0-dev). The ticket has two parts, and they have
    different answers today.

    Part 1, the “must have” – the fatal error – is fixed. LocalizationStateSelector
    now checks for null before using the State object, so
    “Call to a member function isCustomState() on null” can no longer happen; the
    wizard just returns early.

    Part 2, the “could have” – columnsOverrides support – is still open, and it is
    more than cosmetic. With allowLanguageSynchronization set through
    columnsOverrides (I used tt_content.bodytext for CType textmedia), I get:

    State::getFieldNames(‘tt_content’)  -> []
    State::isApplicable(‘tt_content’) -> false
    State::fromJSON(‘tt_content’, null) -> null

    The reason is that tt_content has no base column with
    allowLanguageSynchronization at all in a default installation (only pages has),
    so the whole table is considered not applicable. Consequences:

    • LocalizationStateSelector renders nothing – no radio buttons, silently.
    • DataMapProcessor::getFieldNamesToBeHandled() also receives an empty list, so
      the synchronization itself does not happen either, not just the UI.

    The cause is State::getFieldNames(), which only looks at the base schema.
    The schema layer already knows the override – getSubSchema(‘textmedia’)
    ->getField(‘bodytext’) returns the behaviour with allowLanguageSynchronization
    set – State simply does not look there.

    It is not a two-liner though: State::getFieldNames() only receives a table name,
    not the record type. Merging all sub schemata would enable
    allowLanguageSynchronization for every type of the table instead of the
    configured one, and sanitize()/enrich() would then write wrong l10n_state
    values. A proper fix has to pass the record type into
    State::getFieldNames()/fromJSON()/create(). Both callers would have it at hand.

    For the record, #101435 (“Support columnsOverrides in DataHandler”, commit
    4930c561853) does not cover this: it only touches DataHandler.php,
    BackendUtility.php and CreateSiteConfiguration.php – State.php and
    DataMapProcessor.php are untouched.

    Suggestion: keep this open but retitle it to the remaining part, e.g.
    “allowLanguageSynchronization via columnsOverrides is ignored by
    State/DataMapProcessor”, and raise the version from 9 to main. The workaround
    from the first post – configuring allowLanguageSynchronization in columns
    instead of columnsOverrides – still applies.

  4. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-13T11:52:01+00:00" > 11/13/26, 11:52 </span>

    Thanks for the re-check, Georg. One addition, because it changes the picture for the second part.

    The fatal error from the original report was fixed with #104693 / #104403 (https://review.typo3.org/c/Packages/TYPO3.CMS/+/85721, released to main and 12.4). That patch did two things:

    • LocalizationStateSelector returns early if State::fromJSON() yields null.
    • TcaMigration::removeAllowLanguageSynchronizationFromColumnsOverrides() removes [behaviour][allowLanguageSynchronization] from all columnsOverrides and adds a TCA migration message for the integrator.

    Because of the migration, the override never reaches the schema layer in a regularly loaded TCA. The sub schema only carries the flag if $GLOBALS['TCA'] is modified at runtime, after the migration has run. So in a real installation the option is not silently ignored: it is removed and reported, and this is documented in “Important: #104693 – Setting allowLanguageSynchronization via columnsOverrides”.

    What remains is the “could have” part: supporting allowLanguageSynchronization per record type. This is a feature and not a small one:

    • State::create(), fromJSON(), isApplicable() and getFieldNames() only know the table name and would need the record type.
    • DataMapProcessor decides per table whether and which fields to synchronize, and would have to do this per record.
    • It needs a definition of what happens if a translation has a different type than its language parent, and what happens to the stored l10n_state when the type of a record changes.
    • The TCA migration and the Important RST would have to be removed again.

    I am closing this issue as the reported error is resolved with #104693. The workaround from the description is still the way to go: set allowLanguageSynchronization in columns instead of columnsOverrides. If someone needs synchronization per record type, please open a new feature issue with the use case, and reference this one.