Issue Bug Closed

#61543Language Fallback fails when displaying records, which have translation for other languages but not the current language

Andre Rinas 09/11/14, 16:30 updated 09/17/15, 14:26

Description

We are building on an extension with extbase and found something special:

If you have for example 3 Languages (en = 0, de =1, fr = 2) and

you create 4 Records in english and nothing else
- > all 4 records are showing up in all 3 languages in english

If you create translation for records in fr you then:
- > all 4 records showing in english => right
- > all 4 records showing in french => right
- > none record showing in german => wrong!

After some debugging we found out that addSysLanguageStatement in file:
/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php

makes the error.

if ($mode === 'strict') {
    $additionalWhereClause = $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . '=-1' .
        ' OR (' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . ' = ' . (int)$querySettings->getLanguageUid() .
        ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] . '=0' .
        ') OR (' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . '=0' .
        ' AND ' . $tableName . '.uid IN (SELECT ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] .
        ' FROM ' . $tableName .
        ' WHERE ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] . '>0' .
        ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . '=' . (int)$querySettings->getLanguageUid() ;
} else {
    $additionalWhereClause .= ' OR (' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . '=0' .
        ' AND ' . $tableName . '.uid NOT IN (SELECT ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] .
        ' FROM ' . $tableName .
        ' WHERE ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] . '>0' .    

‘ AND ‘ . $tableName . ‘.’ . $GLOBALS[‘TCA’][$tableName][‘ctrl’][‘languageField’] . ‘>0’;

 }

The marked line is excluding uid’s for fallback, if any translation for the record is found, but it has to remove only records that are in the current language.
The line should be deleted or extended.

So if you are in german (sys_language_uid = 1 in my example) it should be:
’ AND ‘ . $tableName . ‘.’ . $GLOBALS[‘TCA’][$tableName][‘ctrl’][‘languageField’] . ‘=1’;

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.