Project

General

Profile

Actions

Bug #77298

closed

Wrong language overlay logic in extbase

Added by Markus Klein almost 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase + l10n
Target version:
-
Start date:
2016-07-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.0
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

setup

Model A has a relation to model B (eg categories).
Model A can be translated.
The relation to B is only maintained in the default language
We assume content_fallback mode.

action

Fetching translated records for A which are assigned to B with uid 1.

expected result

A list of A-records.

actual result

Empty result

issue

Invalid SQL code generated in Typo3DbQueryParser::getSysLanguageStatement

affected versions

6.0 to 8

example

ext:news with categories.

  • Create a record in default language
  • Assign a category to your news.
  • Translate the news (but do not a assign a category in the translation, since this should be fetched from default lang)
  • Create a plugin and select a category filter there

The result is "no news found".

This is an extraction of the invalid SQL generated with comments inside.

# limit the result to the selected category uid 1 only
# this part only allows for news records of default language (correct query part!)
tx_news_domain_model_news.uid IN (
    SELECT uid_foreign FROM sys_category_record_mm 
    WHERE uid_local='1' AND sys_category_record_mm.fieldname = 'categories'
    AND sys_category_record_mm.tablenames = 'tx_news_domain_model_news'
)

# this part is the killer
AND (
   # either we allow only translated records (which never have a direct category relation)
    tx_news_domain_model_news.sys_language_uid IN (1,-1)
    OR (
  # or we allow news records, which do not have a translation in the language uid 1 at all (bad luck if all news are properly translated)
        tx_news_domain_model_news.sys_language_uid=0
        AND tx_news_domain_model_news.uid NOT IN (
            SELECT tx_news_domain_model_news.l10n_parent
            FROM tx_news_domain_model_news 
            WHERE tx_news_domain_model_news.l10n_parent>0
            AND tx_news_domain_model_news.sys_language_uid=1
            AND tx_news_domain_model_news.deleted=0
        )
    )
)

remarks

It is completely wrong to select records directly in the translated language in an overlay scenario as any other where condition (eg category selection above) of the query, which covers relation filtering, will always relate to the default language record. There current SQL excludes exactly those default records (since they have a translation) and all those where clauses fail.

The code was introduced with https://review.typo3.org/10188

external resources

http://www.dmitry-dulepov.com/2015/01/strange-code-in-extbase-persistance.html


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #32216: OrderBy on translated records doesn't work properlyClosed2011-11-30

Actions
Related to TYPO3 Core - Bug #82363: Make Extbase translation handling consistent with typoscriptClosedTymoteusz Motylewski2017-09-07

Actions
Related to TYPO3 Core - Bug #63694: extbase: strict mode and bug with queries in regards addSysLanguageStatement - e.g. contains ignores different MM translationsClosed2014-12-09

Actions
Actions

Also available in: Atom PDF