Issue Bug Closed

#81141ContentObjectRenderer->getRecords() returns incorrectly sorted records in foreign languages

Sven Radetzky 05/04/17, 17:31 updated 10/18/26, 16:10

Description

The issue occurs for example when using the TypoScript CONTENT object:

For example with the following config:

lib.columns.content = CONTENT
lib.columns.content {
    table = tt_content
    select {
        where = colPos=0
        pidInList = this
        selectFields = *
        includeRecordsWithoutDefaultTranslation = 1
        orderBy = sorting
        languageField = sys_language_uid
    }
    renderObj =< tt_content
}

The order by which the records are sorted is determined only by the executed query in ContentObjectRenderer->getRecords().

Only afterwards the $tsfe->sys_page->versionOL(…) and $tsfe->sys_page->getRecordOverlay(…) functions are called on a per record basis without taking into account that the changed record values could also have changed sorting values.

Therefore, while the records arrive in the frontend with the correct values in the sorting field, they are still sorted by the sorting values of the original records, while “records without default translation” are incorrectly positioned throughout.

Tested against TYPO3 CMS 7.6.18.

Language config:

#### German language, default
config {
    sys_language_uid = 0
    sys_language_overlay = hideNonTranslated
    sys_language_mode = strict
    language = de
    locale_all = de_DE.UTF-8
    htmlTag_langKey = de
}

page.meta.language = de

#### English language, sys_language.uid = 1
[globalVar = GP:L = 1]
    config.sys_language_uid = 1
    config.language = en
    config.locale_all = en_GB.UTF-8
    config.htmlTag_langKey = en
    page.meta.language = en
[global]

and PageTSConfig:

mod.SHARED {
  defaultLanguageFlag = de
  defaultLanguageLabel = Deutsch
}

mod.web_layout.defLangBinding = 0
mod.web_layout.allowInconsistentLanguageHandling = 1

TCAdefaults.pages.l18n_cfg = 2
TCEFORM.pages.l18n_cfg.disabled = 1

Reviews 0

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

History 7

  1. Richard Haeser commented <span data-processor="relativetime" data-value="2017-10-23T08:56:08+00:00" > 10/23/17, 08:56 </span>

    We have the same issue. Any news on this? I’m aware of the issues with inconsistent language handling and that you shouldn’t do that, but in a site with thousands of translated pages, it is hard to go back.

  2. Tymoteusz Motylewski commented <span data-processor="relativetime" data-value="2017-10-23T09:18:41+00:00" > 10/23/17, 09:18 </span>

    To my knowledge, taking into account original record sorting field is correct (when using sys_language_overlay set to 1 or hideNonTranslated).
    If you want to have independent sorting of records in translation you should use sys_language_overlay = 0.

  3. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-10-18T16:10:07+00:00" > 10/18/26, 16:10 </span>

    I checked this against current main (v15). The behaviour is unchanged: ContentObjectRenderer::getRecords() sorts in SQL on the default-language records plus the records without a default translation. The overlays run afterwards, per record, and the result is not re-sorted.

    Reproduction with the fixtures of LocalizedSiteContentRenderingTest (default records sorted 256/512/768, the Danish translation of element 3 set to sorting=100, the floating Danish record set to sorting=300):

    strict:   [DA] #1 (sorting 384) | [DA] floating (300) | [DA] #3 (100)
    fallback: [DA] #1 (384) | [DA] floating (300) | #2 (512) | [DA] #3 (100)

    This is intended for the overlay modes (fallbackType: strict and fallback, formerly sys_language_overlay = 1 / hideNonTranslated). Records are fetched in the default language and then overlaid, so translations always follow the order of the default language. The sorting value of a translated record has no effect there. This is what makes “connected mode” work, and changing it would break existing sites.

    If a language needs its own order, use fallbackType: free in the site configuration. Then only the records of that language are fetched and sorted by their own sorting values.

    The remaining side effect concerns records without a default-language parent (includeRecordsWithoutDefaultTranslation). They are placed by comparing their own sorting value with the default-language values. On pages that mix connected and free translations, that position can seem arbitrary. Mixing both modes on one page is inconsistent anyway, and the page module warns about it.

    I’d close this issue as “works as designed”. If someone needs a specific order for mixed pages, please open a new feature request describing the expected behaviour.

    If you have issue because of an old installation, also try dbdoctor extension which fixes a lot of inconsistencies from previous versions.